To add dialogs, we need to follow these steps:
Inside the UI group, add a new Objective-C class called
Dialog
, which derives fromSPSprite
.Implement the dialog initializer with the following lines of code:
-(id) init { if ((self = [super init])) { SPImage *background = [SPImage imageWithTexture:[[Assets textureAtlas:@"ui.xml"] textureByName:@"dialog"]]; SPButton *buttonYes = [SPButton buttonWithUpState:[[Assets textureAtlas:@"ui.xml"] textureByName:@"dialog_yes"] text:@"Yes"]; SPButton *buttonNo = [SPButton buttonWithUpState:[[Assets textureAtlas:@"ui.xml"] textureByName:@"dialog_no"] text:@"No"]; buttonYes.x = 24.0f; buttonYes.y = background.height - buttonYes.height -40.0f; buttonNo.x = buttonYes.x + buttonYes.width - 20.0f; buttonNo.y = buttonYes.y; [self addChild:background]; ...