O'Reilly logo

Python Game Programming By Example by Joseph Howse, Alejandro Rodas de Paz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Cocos2d actions

In our previous game, we manipulated our sprites directly through their members, especially the position attribute. The game loop updated each actor with the elapsed time from the previous frame.

However, our tower defense game will be based mainly on cocos2d actions, which are orders to modify object attributes such as the position, rotation, or scale. They are executed by calling the do() method of the CocosNode class. Therefore, any sprite, layer, or scene can be a valid target of an action.

The actions that we will cover in this section can be divided into two main groups: interval actions and instant actions.

Interval actions

These actions have a duration, and their execution ends after that certain duration. For instance, if ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required