Create and run animation in a sequence

Hi,
I am working on 2048 game. Here I want to move the tile from one block to the next tile holder with animation according to the swipe direction in android or iOS and then move the tile from next block to further next or create a new tile after adding same numbers, I want to repeat this process until tile reaches to the destination block according to the rules of the game.

I also want to apply this on all available tiles in the game. I know there is option to create sequence of actions but I am confused about to create the animation according to each individual tile.

For Now I tried to move but it is not looking cool, it performs the complete process in a single short.
I hope you may help me to solve this problem. Your help would be appreciated.

Thank You!!!

js-tests has examples for this.

Hi,

You may want to start with some delaying (DelayTime action). You must know which action should be performed first etc. Then just use Sequence action with this delay. You may also add callback to “vertical” actions and then (in this callback) call “horizontal” actions.

Everything depends on what data you have and what do you want to achieve (e.g. how the blocks should move, which direction should be first etc.).

You should also look at “Ease” actions. You may get really nice results with them.

Best!

Thank you so much for your reply

Thank you so much for your reply, but I want to create a sequence on run time and the action should be decided according to the rules of the game.

Yes. Actions are time based and it is up to you and your game logic when to run them.

So, for example you have board with fields (A). User makes some action, like touch. Game logics “moves” fields (B). Now, you know src and dest positions of all fields.

I see there 2 possible solutions:

  1. During the transitions from A to B you create data structure of the “movement”. Then, based on this structure you create actions and animate everything in the UI.

  2. When game logic is “moving” the fields you create actions “in the runtime”. You don’t need any additional structure to track the movement, but also you don’t know all the moves.

Creating the sequence action is easy, the problem is to create the “queue” of the actions so that animation looks good.

As @slackmoehrle already mentioned, take a look at js-tests: Match 3 Puzzle Game , it should help.