-
Notifications
You must be signed in to change notification settings - Fork 1
/
Menu.m
67 lines (51 loc) · 2.38 KB
/
Menu.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#import "Menu.h"
#import "Game.h"
#import "AppDelegate.h"
#import "LevelSelect.h"
@implementation Menu
- (id)init {
if ((self = [super init])) {
SPImage *menubg = [SPImage imageWithContentsOfFile:@"BlueBG.png"];
[self addChild:menubg];
SPTextureAtlas *menuAtlas = [SPTextureAtlas atlasWithContentsOfFile:@"UIAtlas.xml"];
SPImage *title = [SPImage imageWithTexture:[menuAtlas textureByName:@"AirPodTitle"]];
title.x = 34;
title.y = 24;
[self addChild:title];
SPButton *playButton = [SPButton buttonWithUpState:[menuAtlas textureByName:@"playBtn"]];
playButton.x = 96;
playButton.y = 148;
playButton.name = @"ModePick";
[playButton addEventListener:@selector(buttonPressed:) atObject:self forType:SP_EVENT_TYPE_TRIGGERED];
SPButton *storeButton = [SPButton buttonWithUpState:[menuAtlas textureByName:@"storeBtn"]];
storeButton.x = 102;
storeButton.y = 214;
storeButton.name = @"Store";
[storeButton addEventListener:@selector(buttonPressed:) atObject:self forType:SP_EVENT_TYPE_TRIGGERED];
SPButton *helpButton = [SPButton buttonWithUpState:[menuAtlas textureByName:@"helpBtn"]];
helpButton.x = 114;
helpButton.y = 276;
helpButton.name = @"Help";
[helpButton addEventListener:@selector(buttonPressed:) atObject:self forType:SP_EVENT_TYPE_TRIGGERED];
SPButton *scoresButton = [SPButton buttonWithUpState:[menuAtlas textureByName:@"scoresBtn"]];
scoresButton.x = 100;
scoresButton.y = [SPStage mainStage].height - 59;
[scoresButton addEventListener:@selector(scoresButtonPressed:) atObject:self forType:SP_EVENT_TYPE_TRIGGERED];
[self addChild:playButton];
[self addChild:storeButton];
[self addChild:helpButton];
[self addChild:scoresButton];
}
return self;
}
-(void) buttonPressed:(SPEvent *)event {
SPButton *button = (SPButton *)event.target;
Class sceneClass = NSClassFromString(button.name);
id newScene = [[sceneClass alloc] init];
[(Game *)[SPStage mainStage] showScene:newScene];
}
-(void) scoresButtonPressed:(SPEvent *)event {
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate showLeaderboard];
}
@end