-
Notifications
You must be signed in to change notification settings - Fork 3
/
MenuScene.m
47 lines (43 loc) · 1.17 KB
/
MenuScene.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
//
// MenuScene.m
// SimpleGame
//
// http://monoclestudios.com/cocos2d_whitepaper.html
// This is free software - see LICENSE for details
//
#import "MenuScene.h"
#import "GameScene.h"
@implementation MenuScene
- (id) init {
self = [super init];
if (self != nil) {
Sprite * bg = [Sprite spriteWithFile:@"menu.png"];
[bg setPosition:ccp(240, 160)];
[self addChild:bg z:0];
[self addChild:[MenuLayer node] z:1];
}
return self;
}
@end
@implementation MenuLayer
- (id) init {
self = [super init];
if (self != nil) {
[MenuItemFont setFontSize:20];
[MenuItemFont setFontName:@"Helvetica"];
MenuItem *start = [MenuItemFont itemFromString:@"Start Game" target:self selector:@selector(startGame:)];
MenuItem *help = [MenuItemFont itemFromString:@"Help" target:self selector:@selector(help:)];
Menu *menu = [Menu menuWithItems:start, help, nil];
[menu alignItemsVertically];
[self addChild:menu];
}
return self;
}
-(void)startGame: (id)sender {
GameScene * gs = [GameScene node];
[[Director sharedDirector] replaceScene:gs];
}
-(void)help: (id)sender {
NSLog(@"help");
}
@end