私はCCLayerColorをフェードしたいと思っていますが、これはかなり簡単に思えますが、うまくいきません...これが私がすることです:
LoadingScreen.h
@interface LoadingScreen : CCLayerColor{
}
-(id)init;
-(void)setOpacity:(GLubyte)opacity;
@end
LoadingScreen.m
@implementation LoadingScreen
-(id)init{
if ((self=[super initWithColor:ccc4(66 , 66, 66, 255)])){
self.isTouchEnabled = NO;
}
return self;
}
-(void)setOpacity:(GLubyte)opacity{
for( CCNode *node in [self children] )
{
if( [node conformsToProtocol:@protocol(CCRGBAProtocol)] )
{
NSLog(@"conforms to protocol!");
[(id<CCRGBAProtocol>) node setOpacity: opacity];
}
}
}
@end
GameLayer.m
-(id)init{
timer = [NSTimer scheduledTimerWithTimeInterval:0.001 target:self selector:@selector(checkIfLoaded) userInfo:nil repeats:YES];
}
-(void)checkIfLoaded{
NSLog(@"still doing stuff");
if(doneInitializing ==YES){
NSLog(@"done");
[timer invalidate];
NSLog(@"FADE NOW !!!!");
id fade = [CCFadeOut actionWithDuration:2.5];
[loadingLayer runAction:fade];
[self performSelector:@selector(removeLoadingLayer) withObject:nil afterDelay:3.5];
}
if(loadingScreenPushed == NO && doneInitializing == NO){
NSLog(@"adding Layer");
loadingScreenPushed = YES;
loadingLayer = [LoadingScreen node];
[self addChild:loadingLayer z:10];
}
}