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.
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 = [CCSprite spriteWithImageNamed:@"imgBoard.png"]; board.position = ccp(winSize.width * 0.625, winSize.height/2); [self addChild:board];
Let's run the game, and uh oh! We seem to have run into the first issue with our prototype. Although it's not...