O'Reilly logo

Sparrow iOS Game Framework Beginner's Guide by Johannes Stein

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 a text field to the dialog

To draw text on the screen, we need to follow these steps:

  1. As shown in the following line of code, add a property called content, which is a pointer to SPTextField, inside the Dialog.h file:
    @property SPTextField *content;
  2. In the Dialog initializer, create the following content instance and position it between the title box and the buttons:
    _content = [SPTextField textFieldWithWidth:background.width - 48.0f height:background.height - 150.0f text:@"Dialog default text"];
    _content.x = 24.0f;
    _content.y = 50.0f;
  3. Add the content property to the display tree, as shown in the following code:
    [self addChild:background];
    [self addChild:buttonYes];
    [self addChild:buttonNo];
    [self addChild:_content];
    
  4. Switch ...

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