Book Image

Learning iPhone Game Development with Cocos2D 3.0

By : Kirill Muzykov
Book Image

Learning iPhone Game Development with Cocos2D 3.0

By: Kirill Muzykov

Overview of this book

Table of Contents (19 chapters)
Learning iPhone Game Development with Cocos2D 3.0
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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