crispin Posted May 9, 2016 Share Posted May 9, 2016 I've been using `game.camera.onShakeComplete` for running functions after animations are complete, but each time it adds a new instance to be run. I've been using game.camera.shake(0.02, 250, true, Phaser.Camera.SHAKE_HORIZONTAL, true); game.camera.onShakeComplete.add(function(){runFunction()}, this) to run my code, but I just realised that this adds another function to be run each time, and I can't really have just one for the entire game because they need to do different things. My questions really boil down to: Can I have a callback per game.camera.shake or can I only have one global one? Can I clear game.camera.onShakeComeplete so I can add a new one each time? It's probably not that efficient but it'd work. Is there a way to pass arguments from game.camera.shake to the onShakeComplete so I can have a switch statament in there or something? Thanks. Link to comment Share on other sites More sharing options...
rich Posted May 9, 2016 Share Posted May 9, 2016 camera.onShakeComplete.addOnce(a, this); camera.onShakeComplete.removeAll(); camera.onShakeComplete.add(callback, context, priorityID, arg1, arg2, etc); addOnce will add a single callback. So it doesn't matter how many times 'complete' runs, the callback is only fired once. Once fired you can add it again. removeAll removes all bound callbacks from the signal. The final line shows how to pass arguments. crispin 1 Link to comment Share on other sites More sharing options...
apiapia Posted November 3, 2018 Share Posted November 3, 2018 but now onShakeComplete update to what? m very confused! Link to comment Share on other sites More sharing options...
Recommended Posts