-(void) directorDidReshapeProjection:(CCDirector*)director
{
if(director.runningScene == nil) {
// Add the first scene to the stack. The director will draw it immediately into the framebuffer. (Animation is started automatically when the view is displayed.)
// and add the scene to the stack. The director will run it when it automatically when the view is displayed.
[director runWithScene: [IntroLayer scene]];
}
}
@end
在AppDelegate.m对场景进行初始化时,导演类会跳转到场景→IntroLayer scene
这个场景是在IntroLayer里新建的类型为CCScene
+(CCScene *) scene
这个场景会一闪而过,这个文件的最下面有个onEnter的实例方法,会直接跳转到另一个场景→HelloWorldLayer scene
在HelloWorldLayer初始化时,init
-(id) init
{
// always call "super" init
// Apple recommends to re-assign "self" with the "super's" return value
if( (self=[super initWithColor:(ccc4(255,0,0,150))])) {
......
}
return self;
}
这里的if( (self=[super initWithColor:(ccc4(255,0,0,150))])) {
......
会设置背景颜色!