Now, using touch, we move the player to the touched location on the screen.
To do this, we use CCActions. CCActions are predefined classes of Cocos2d-x that can be used to perform various functions on an object over a period of time.
We can also combine multiple actions together to perform actions one after the other using CCSequence. Let's first see how to make the player move from the initial position to the desired touch location. Also, to ensure that the character doesn't simply go from point A to B, we add an easing action that will slowly increase the speed of the character when starting. When reaching the destination, it will slowly decrease the speed and bring the character to a halt.
To do this, we have to get the location ...