Game Development Reference
In-Depth Information
scene. You'll find the example implementation of the LoadingScene class in the
ScenesAndLayers01 project.
In effect, the LoadingScene class acts as an intermediate scene. It's derived from
the cocos2d CCScene class. You don't have to create a new LoadingScene for
each transition; you can use one scene for which you simply specify the target scene
you'd like to be loaded. An enum works best for this; it's defined in the LoadingS-
cene header file shown in Listing 5-2 .
Listing 5-2. LoadingScene.h
typedef enum
{
TargetSceneINVALID = 0,
TargetSceneFirst,
TargetSceneSecond,
TargetSceneMAX,
} TargetSceneTypes;
// LoadingScene is derived directly from Scene. We don't need a CCLayer for this scene.
@interface LoadingScene : CCScene
{
TargetSceneTypes targetScene;
}
+(id) sceneWithTargetScene:(TargetSceneTypes)sceneType;
-(id) initWithTargetScene:(TargetSceneTypes)sceneType;
Tip It's good practice to set the first enum value to be an INVALID value, un-
less you intend to make the first the default. Variables in Objective-C are initial-
ized to 0 automatically unless you specify a different value.
You can also also add a MAX or NUM entry at the end of the enum if you intend
to iterate over every enum value, as in:
for (int i = TargetSceneINVALID + 1; i < TargetScenesMAX;
i++) { .. }
 
 
Search Nedrilad ::




Custom Search