O'Reilly logo

Cocos2d-x Game Development Essentials by Gareth Jones, Arutosh Gurung, Frahaan Hussain

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

Animation

Until now, all the actions that have been applied have been done so in a linear fashion. For example, when a MoveBy action was applied, it would move at a constant speed throughout; this could be overcome by sequencing several movement actions to provide the illusion of momentum, for instance. However, this is very inefficient and extremely tedious. Cocos2d-x provides an immense number of animations, all of which can be found in Cocos2d-x's API guide at http://www.cocos2d-x.org/wiki/Reference. This section will cover a single example, which will be a great basis for moving forward:

The following is the syntax:

auto action = ActionName::create(actionProperties);
playerSprite->runAction(Animation(action));

The following is the example's code: ...

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