Book Image

Sparrow iOS Game Framework Beginner's Guide

By : Johannes Stein
Book Image

Sparrow iOS Game Framework Beginner's Guide

By: Johannes Stein

Overview of this book

Table of Contents (20 chapters)
Sparrow iOS Game Framework Beginner's Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Afterword
Index

Time for action – updating the scene and dialog classes


To add our first buttons, use the following steps:

  1. Open the Dialog.h file.

  2. Add properties for both Yes and No buttons using the following code:

    @propertySPButton *buttonYes;
    @propertySPButton *buttonNo;
  3. Switch to Dialog.m.

  4. Refactor all references from the local variables to use the properties.

  5. Update the positions of _title and _content using the following code:

    content = [SPTextField textFieldWithWidth:background.width - 96.0f height:background.height - 150.0f text:@"Dialog default text"];
    _content.x = 52.0f;
    _content.y = 66.0f;
    
    [SPTextField registerBitmapFontFromFile:@"PirateFont.fnt"];
    
    _title = [SPTextField textFieldWithWidth:background.width * 0.6 height:30.0f text:@"Dialog"];
    _title.fontName = @"PirateFont";
    _title.color = SP_WHITE;
    
    _title.x = 36.0f;
    _title.y = 26.0f;
  6. In both onButtonYes and onButtonNo, add self.visible = NO; as the first statement.

  7. In Scene.h, declare a method called reset using the following line of code:

    -(void) reset...