-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainMenuScene.m
145 lines (95 loc) · 5.2 KB
/
MainMenuScene.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
//
// MainMenuScene.m
// Münar Lander
//
// Created by Matthew Dutton on 4/15/14.
// Copyright (c) 2014 Matthew Dutton. All rights reserved.
//
#import "ViewController.h"
#import "MainMenuScene.h"
#import "GameScreen.h"
#import "OptionsScene.h"
@implementation MainMenuScene
@synthesize viewSize;
-(id)initWithSize:(CGSize)size {
if (self = [super initWithSize:size]) {
viewSize = size;
gameHelper = [GameDataHelper getSharedInstance];
/* Setup your scene here */
self.backgroundColor = [SKColor clearColor];
SKSpriteNode* backImage = [SKSpriteNode spriteNodeWithImageNamed:@"MAINMENU.png"];
backImage.position = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame));
[self addChild:backImage];
SKLabelNode *myLabel = [SKLabelNode labelNodeWithFontNamed:@"Marker Felt"];
myLabel.text = @"Münar Lander";
myLabel.fontSize = 60;
myLabel.position = CGPointMake(512,512*1.2);
[self addChild:myLabel];
SKSpriteNode* playButton = [SKSpriteNode spriteNodeWithImageNamed:@"LARGEBUTTON"];
playButton.size = CGSizeMake( 175 * 2 , 110 );
playButton.position = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame) + playButton.size.height / 1.5 );
playButton.name = @"playButton";
[self addChild:playButton];
SKLabelNode* playLabel = [SKLabelNode labelNodeWithFontNamed:@"Marker Felt"];
playLabel.text = @"Play Game";
playLabel.fontColor = [SKColor blackColor];
playLabel.verticalAlignmentMode = SKLabelVerticalAlignmentModeCenter;
playLabel.name = @"playButton";
[playButton addChild:playLabel];
SKSpriteNode* optionsButton = [SKSpriteNode spriteNodeWithImageNamed:@"LARGEBUTTON"];
optionsButton.size = CGSizeMake( 175 * 2 , 110 );
optionsButton.position = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame) - playButton.size.height / 1.5 );
optionsButton.name = @"optionsButton";
[self addChild:optionsButton];
SKLabelNode* optionsLabel = [SKLabelNode labelNodeWithFontNamed:@"Marker Felt"];
optionsLabel.fontColor = [SKColor blackColor];
optionsLabel.text = @"Options";
optionsLabel.name = @"optionsButton";
optionsLabel.verticalAlignmentMode = SKLabelVerticalAlignmentModeCenter;
[optionsButton addChild:optionsLabel];
SKSpriteNode* leaderBoardButton = [SKSpriteNode spriteNodeWithImageNamed:@"LARGEBUTTON"];
leaderBoardButton.size = CGSizeMake( 175 * 2 , 110 );
leaderBoardButton.position = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame) - playButton.size.height * 2 );
leaderBoardButton.name = @"leaderBoardButton";
[self addChild:leaderBoardButton];
SKLabelNode* leaderBoardLabel = [SKLabelNode labelNodeWithFontNamed:@"Marker Felt"];
leaderBoardLabel.fontColor = [SKColor blackColor];
leaderBoardLabel.text = @"Leaderboard &";
leaderBoardLabel.name = @"leaderBoardButton";
[leaderBoardButton addChild:leaderBoardLabel];
SKLabelNode* achievementsLabel = [SKLabelNode labelNodeWithFontNamed:@"Marker Felt"];
achievementsLabel.fontColor = [SKColor blackColor];
achievementsLabel.position = CGPointMake(leaderBoardLabel.position.x, leaderBoardLabel.position.y - 30);
achievementsLabel.text = @"Achievements";
achievementsLabel.name = @"leaderBoardButton";
[leaderBoardButton addChild:achievementsLabel];
}
return self;
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInNode:self];
SKNode *node = [self nodeAtPoint:location];
SKView * skView = (SKView *)self.view;
skView.showsFPS = NO;
skView.showsNodeCount = NO;
if ([node.name isEqualToString:@"playButton"]) {
GameScreen * scene = [GameScreen sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
SKTransition *reveal = [SKTransition revealWithDirection:SKTransitionDirectionLeft duration:.5];
[skView presentScene:scene transition:reveal];
} else if ([node.name isEqualToString:@"optionsButton"]){
SKScene * scene = [OptionsScene sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
SKTransition *reveal = [SKTransition revealWithDirection:SKTransitionDirectionDown duration:.5];
[skView presentScene:scene transition:reveal];
} else if ([node.name isEqualToString:@"leaderBoardButton"]){
LeaderBoardScene* leaderboard = [[LeaderBoardScene alloc]initWithSize:viewSize];
SKTransition* reveal = [SKTransition revealWithDirection:SKTransitionDirectionLeft duration:0.5];
[skView presentScene:leaderboard transition:reveal];
}
}
-(void)update:(CFTimeInterval)currentTime {
/* Called before each frame is rendered */
}
@end