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:

Time for action – displaying the welcome label

Displaying the Hello! label and the earth sprite

Tip

If you have any trouble with the ...

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.