Game Development Reference
In-Depth Information
In the case of the LoadingScene , it's not necessary, but I tend to add these
entries merely out of habit, even if I don't need them.
This brings me to the LoadingScene class implementation of the ScenesAndLayer-
s01 project in Listing 5-3 . You'll notice that the scene is initialized differently and that
it uses scheduleUpdate to delay replacing the LoadingScene with the actual
target scene.
Listing 5-3. The LoadingScene Class Uses a Switch to Decide Whether to Load the Tar-
get Scene
+(id) sceneWithTargetScene:(TargetSceneTypes)sceneType;
return [[self alloc] initWithTargetScene:sceneType];
-(id) initWithTargetScene:(TargetSceneTypes)sceneType
if ((self = [super init]))
targetScene = sceneType;
CCLabelTTF* label = [CCLabelTTF labelWithString:@"Loading . . ."
fontName:@"Marker Felt"
CGSize size = [CCDirector sharedDirector].winSize;
label.position = CGPointMake(size.width / 2, size.height / 2);
[self addChild:label];
// Must wait one frame before loading the target scene!
[self scheduleOnce:@selector(loadScene:) delay:0.0f];
return self;
-(void) loadScene:(ccTime)delta
Search Nedrilad ::

Custom Search