-1

我将此场景添加到项目并在 ProjectRunDelegate 运行它,当方法 cFadeAndShow 启动时它下降了谁能告诉我有什么问题吗?

我使用 xCode 3.2.6 和 cocos2d 1.0.1

或者也许有人已经有工作启动场景来在游戏开始时显示一些公司的标志

谢谢

#import "SplashScene.h"
@implementation SplashScene

-(id) init {
    if ( (self = [super init])) {   
        [self addChild:[SplashLayer node]];

    }
    return self;
}
-(void)dealloc{
    [super dealloc];
}
@end

@implementation SplashLayer

-(id) init {
    if ( (self = [super init])) {

        self.isTouchEnabled = YES;

        NSMutableArray * splashImages = [[NSMutableArray alloc] init];
        for (int i =1; i<=2; i++) {
            CCSprite *splashImage = [CCSprite spriteWithFile:[NSString stringWithFormat:@"splash%d.png",i]];
            if (splashImage == nil) {
                CCLOG(@"splashImage is nil");
            }
            [splashImage setPosition:ccp(240,160)];
            [self addChild:splashImage];
            if (i!=1) 
                [splashImage setOpacity:0];
                [splashImages addObject:splashImage];
        }
        [self fadeAndShow:splashImages];
    }
    return self;
}

-(void) fadeAndShow:(NSMutableArray *) images{   // add the meehods

    if ([images count]<=1) {
        [images release];
        [[CCDirector sharedDirector]replaceScene:[GameScene scene]]; 
    }

    else {

        CCSprite *actual = (CCSprite *)[images objectAtIndex:0];
        [images removeObjectAtIndex:0];

        CCSprite * next = (CCSprite *)[images objectAtIndex:0];

        [actual runAction:[CCSequence actions:[CCDelayTime actionWithDuration:2], [CCFadeOut actionWithDuration:1],
                           [CCCallFuncN actionWithTarget:self selector:@selector(remove:)],nil]];
        [next runAction:[CCSequence actions:[CCDelayTime actionWithDuration:2], [CCFadeIn actionWithDuration:1],
                         [CCDelayTime actionWithDuration:2],
                         [CCCallFuncND actionWithTarget:self selector:@selector(cFadeAndShow:data:) data:images],nil]];
    }

}
-(void) cFadeAndShow:(id)sender dara:(void*)data{
    NSMutableArray * images = (NSMutableArray *) data;
    [self fadeAndShow:images];
}
-(void)remove:(CCSprite *)s{
    [s.parent removeChild:s cleanup:YES];
}
-(void)dealloc{
    [super dealloc];
}
@end
4

1 回答 1

0

这是一个答案:

[[CCDirector sharedDirector] replaceScene: [CCTransitionZoomFlipAngular 
    transitionWithDuration:2 
    scene:[GameScene node]
    orientation:kOrientationLeftOver]];
于 2013-04-07T07:14:05.973 回答