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 – displaying the welcome label


Now that we have a world displayed, let's welcome it! Refer to the following steps:

  1. Open the FirstScene.m file and add the following code in the init method, right after the [self addChild:earth]; line.

    //1
    CCLabelTTF* welcome = 
      [CCLabelTTF labelWithString:@"Hello!"
      fontName:@"Helvetica"
      fontSize:32];
    
    //2
    welcome.position = ccp(winSize.width  / 2.0f, 
      winSize.height * 0.9f);
    
    //3
    [self addChild:welcome];
  2. Build and run the project.

You should see the Hello! label at the top half of the screen. Refer to the following screenshot:

Displaying the Hello! label and the earth sprite

Tip

If you have any trouble with the project, you can always compare your project with the completed project in the book's supporting files. You can view the HelloWorld project in the Chapter_02/HelloWorld folder.

What just happened?

This is our Hello part from the Hello World!. The following is a step-by-step description of what we've done:

  1. We created a label object using...