O'Reilly logo

Learning iPhone Game Development with Cocos2D 3.0 by Kirill Muzykov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – adding the win and lose labels

It is time to use our win and lose fonts. Perform the following steps:

  1. Open the GameScene.m file, and add another z-order value at the top:
    typedef NS_ENUM(NSUInteger, Z_ORDER)
    {
        Z_BACKGROUND,
        Z_BATCH_NODE,
        Z_LABELS,
        Z_HUD
    };
  2. Scroll down and add the displayWinLoseLabelWithText: method below the won and lost methods:
    -(void)displayWinLoseLabelWithText:(NSString *)text andFont:(NSString *)fontFileName { CGSize viewSize = [CCDirector sharedDirector].viewSize; CCLabelBMFont *label = [CCLabelBMFont labelWithString:text fntFile:fontFileName]; label.position = ccp(viewSize.width * 0.5f, viewSize.height * 0.75f); [self addChild:label z:Z_LABELS]; label.scale = 0.01f; CCActionScaleTo *scaleUp = [CCActionScaleTo ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required