给cocos-2d的场景设置背景颜色

来源:互联网 发布:环形网络拓扑结构特点 编辑:程序博客网 时间:2024/05/17 00:19

-(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=[superinitWithColor:(ccc4(255,0,0,150))])) {

    ......

    }


return self;

}


这里的if( (self=[super initWithColor:(ccc4(255,0,0,150))])) {

             ......

会设置背景颜色!


0 0
原创粉丝点击