Time for action – updating the scene and dialog classes
To add our first buttons, use the following steps:
Open the
Dialog.h
file.Add properties for both Yes and No buttons using the following code:
@propertySPButton *buttonYes; @propertySPButton *buttonNo;
Switch to
Dialog.m
.Refactor all references from the local variables to use the properties.
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;
In both
onButtonYes
andonButtonNo
, addself.visible = NO;
as the first statement.In
Scene.h
, declare a method calledreset
using the following line of code:-(void) reset...