Book Image

Cocos2d Game Development Essentials

Book Image

Cocos2d Game Development Essentials

Overview of this book

Table of Contents (13 chapters)

Animation in code


Of course, you don't have to use SpriteBuilder when developing for Cocos2d. Sometimes, SpriteBuilder won't be capable of what you are trying to achieve. For these situations, you can of course perform animation within your code. There is a powerful animation engine built straight into Cocos2d.

Moving, scaling, and rotating

In the last section, you saw how you can keep track of time since an event starter and use that knowledge in the update method to change an attribute of a node. You can write all your animation like this, but there is a much simpler way to accomplish simple animations. This method uses CCAction. By using CCAction, you can accomplish many animations, such as move, rotate, and scale.

Here is a list of CCActions available to you in code:

Action

Effect

CCActionMoveTo, CCActionMoveBy

This action moves a node to a position or by a certain amount.

CCActionJumpTo, CCActionJumpBy

This action jumps a node in a parabolic arc to a position or by a certain amount...