Time for action – adding a fire to the scene
We are going to add a campfire to our scene. We will add an image of the campfire base and the fire burning on top of it. To do this, follow these steps:
- Create a new group in
Resources
and call itCampfire
. - Open the book's supporting files at
Chapter_07/Assets/Campfire
and add thecampfire.png
andcampfire-hd.png
images to the Xcode project in theCampfire
group. - Open the
GameScene.m
file and add the following method below theonEnter
method:-(void)startFire { CGSize viewSize = [CCDirector sharedDirector].viewSize; //1 CCSprite *campfire = [CCSprite spriteWithImageNamed:@"campfire.png"]; campfire.position = ccp(viewSize.width * 0.5, viewSize.height * 0.05f); [self addChild:campfire]; //2 CGPoint campfireTop ...
Get Learning iPhone Game Development with Cocos2D 3.0 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.