-
Book Overview & Buying
-
Table Of Contents
Cocos2d-x cookbook
By :
Cocos2d-x has a lot of actions, for example, move, jump, rotate, and so on. We often use these actions in our games. This is similar to an animation, when the characters in a game start their action, the game will come alive. In this recipe you will learn how to use a lot of actions.
Actions are very important effects in a game. Cocos2d-x allows you to use various actions.
To move a sprite by a specified point over two seconds, you can use the following command:
auto move = MoveBy::create(2.0f, Vec2(100, 100)); sprite->runAction(move);
To move a sprite to a specified point over two seconds, you can use the following command:
auto move = MoveTo::create(2.0f, Vec2(100, 100)); sprite->runAction(move);
To uniformly scale a sprite by 3x over two seconds, use the following command:
auto scale = ScaleBy::create(2.0f, 3.0f); sprite->runAction(scale);
To scale the X axis by 5x, and Y axis by 3x over two seconds, use the following command:
auto scale = ScaleBy...
Change the font size
Change margin width
Change background colour