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 = ccp(campfire.position.x, campfire.position.y + campfire.boundingBox.size.height * 0.5f); //3 CCParticleFire *fire = ...