O'Reilly logo

Mastering Cocos2d Game Development by Alex Ogorek

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

Creating nodes and units (sprites)

Remember, everything in Cocos2d is, at its base, a CCNode object. Nodes can have other nodes as children. For example, if you wish to create a character with a jetpack attached, the character can be a CCSprite object (a node object with an image) and the jetpack can be a CCSprite object as a child of the character.

Anyway, this is a chapter about prototypes, and we've yet to create any real gameplay. Let's get that going with a few images, some touch controls, and much more.

Setting up the background

Add the background image to the sprite sheet (or SpriteBuilder), save, publish, and then in the MainScene.m file's init method, add the image to the screen as a CCSprite object below the CCLayoutBox code:

CCSprite *board ...

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