We can easily tell our sprites to perform concrete actions, such as jump, move, skew, and so on. It requires a few lines to get our sprites to execute the desired action.
We can make our sprite move to a specific area of the screen by creating a
MoveTo action and then making the sprite execute the action.
In the following code listing, we are making the bomb fall to the bottom of the screen by simply writing the following code lines:
auto moveTo = MoveTo::create(2, Vec2(sprBomb->getPositionX(), 0 - sprBomb->getContentSize().height/2)); sprBomb->runAction(moveTo);
We have created a
moveTo node that will move the bomb sprite to the current horizontal position, but it will also move it to the bottom of the screen ...