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:

  1. Create a new group in Resources and call it Campfire.
  2. Open the book's supporting files at Chapter_07/Assets/Campfire and add the campfire.png and campfire-hd.png images to the Xcode project in the Campfire group.
  3. Open the GameScene.m file and add the following method below the onEnter 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.