dawg Posted December 23, 2017 Share Posted December 23, 2017 I have sprite that is animated on a board, let's say a 4x4 grid. If the user presses a button, it will move either one one square up/down or left/right. If the user presses the button multiple times, I want for it to step through the movements but as it is right now the sprite will just move diagonally to the final state. Is there a way to enqueue tweens so that each step runs asynchronously? Here's what the transition from one state to another looks like now, where state is the current state number and the location arrays hold the points at every state: game.add.tween(sprite).to({ x: locationX[state], y: locationY[state]}, 500, Phaser.Easing.Linear.None, true); Link to comment Share on other sites More sharing options...
samme Posted January 2, 2018 Share Posted January 2, 2018 You can call to consecutively, like game.add.tween(sprite) .to({ x: x1, y: y1 }, 500) .to({ x: x2, y: y2 }, 500) .to({ x: x3, y: y3 }, 500) .start(); Link to comment Share on other sites More sharing options...
dawg Posted January 3, 2018 Author Share Posted January 3, 2018 How will that work when the user input and number of moves are variable? The locations are getting fetched from a server each time a user clicks to step and a user could click through quickly or slowly. Would you just add to the function and then call them all together at some point? Link to comment Share on other sites More sharing options...
samme Posted January 6, 2018 Share Posted January 6, 2018 You can call to as many times as you need before start, but not after start. Maybe you can use Phaser.Tween#chain instead. Link to comment Share on other sites More sharing options...
espace Posted January 7, 2018 Share Posted January 7, 2018 Hi, and how do you do to declare the delay with this syntax ? Link to comment Share on other sites More sharing options...
Recommended Posts