-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDirector.m
76 lines (51 loc) · 1.47 KB
/
Director.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
//
// Director.m
// EG-TD
//
// Created by Gurcan Yavuz on 10/8/11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import "Director.h"
#import "AbstractScene.h"
@implementation Director
@synthesize currentlyBoundTexture;
@synthesize currentGameState;
@synthesize currentScene;
@synthesize globalAlpha;
@synthesize framesPerSecond;
// Make this class a singleton class
SYNTHESIZE_SINGLETON_FOR_CLASS(Director);
- (id)init {
// Initialize the arrays to be used within the state manager
_scenes = [[NSMutableDictionary alloc] init];
currentScene = nil;
globalAlpha = 1.0f;
return self;
}
- (void)addSceneWithKey:(NSString*)aSceneKey scene:(AbstractScene*)aScene {
[_scenes setObject:aScene forKey:aSceneKey];
}
- (BOOL)setCurrentSceneToSceneWithKey:(NSString*)aSceneKey {
if(![_scenes objectForKey:aSceneKey]) {
return NO;
}
currentScene = [_scenes objectForKey:aSceneKey];
[currentScene setSceneAlpha:1.0f];
[currentScene setSceneState:kGameState_Running];
return YES;
}
- (BOOL)transitionToSceneWithKey:(NSString*)aSceneKey {
// If the scene key exists then tell the current scene to transition to that
// scene and return YES
if([_scenes objectForKey:aSceneKey]) {
[currentScene transitionToSceneWithKey:aSceneKey];
return YES;
}
// If the scene does not exist then return NO;
return NO;
}
- (void)dealloc {
[_scenes release];
[super dealloc];
}
@end