Game Development Reference
In-Depth Information
#import <Foundation/Foundation.h>
@interface SceneManager : NSObject
+(void) presentMainMenu;
+(void) presentGameScene;
@end
The SceneManager.m implements these two class methods—as denoted by the leading
+ character.
For brevity, I declared the variables in Listing 6-11 to be of type id and gave them only
single-letter identifiers just so the lines are short enough to avoid having to add line breaks
in the topic. Of course, single-letter variable names should generally be avoided except for
very short code fragments where there can't be any ambiguities.
Listing 6-11 . SceneManager presents each scene with a specific transition and duration
#import "SceneManager.h"
@implementation SceneManager
+(void) presentMainMenu
{
id s = [CCBReader loadAsScene:@"MainScene"];
id t = [CCTransition
transitionMoveInWithDirection:CCTransitionDirectionLeft
duration:1.0];
[[CCDirector sharedDirector] presentScene:s
withTransition:t];
}
+(void) presentGameScene
{
id s = [CCBReader loadAsScene:@"GameScene"];
id t = [CCTransition
transitionMoveInWithDirection:CCTransitionDirectionRight
duration:1.0];
[[CCDirector sharedDirector] presentScene:s
withTransition:t];
}
@end
Search WWH ::




Custom Search