-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGame.m
executable file
·66 lines (49 loc) · 1.25 KB
/
Game.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
//
// Game.m
// AppScaffold
//
#import "Game.h"
#import "Menu.h"
#import "Play.h"
#import <OpenGLES/ES1/gl.h>
#import <GameKit/GameKit.h>
//#import "ViewController.h"
#import "AppDelegate.h"
// --- class implementation ------------------------------------------------------------------------
@implementation Game
- (id)init
{
if ((self = [super init]))
{
[SPAudioEngine start];
//[self playSong];
Menu *menuScene = [[Menu alloc] init];
[self showScene:menuScene];
}
return self;
}
- (void)playSong
{
tehMusic = [[SPSound alloc] initWithContentsOfFile:@"TheSignal.aifc"];
musicChannel = [tehMusic createChannel];
musicChannel.volume = 1.0f;
musicChannel.loop = YES;
[musicChannel play];
}
- (void)showScene:(SPSprite *)scene
{
if ([self containsChild:currentScene]) {
[self removeChild:currentScene];
}
//if going to gameplay scene, stop music
if ([scene isKindOfClass:[Play class]]){
[musicChannel stop];
}
else if ([currentScene isKindOfClass:[Play class]]) //otherwise, if you're coming from a gameplay scene, pick a new song
{
[musicChannel play];
}
[self addChild:scene];
currentScene = scene;
}
@end