2013-03-20 30 views
-1

我加這一幕突出從而在ProjectRunDelegate 運行它,它下跌的時候方法cFadeAndShow開始 誰能告訴我什麼問題?試圖讓SplashScene(cocos2d的)形成巴勃羅·魯伊斯·的書,它不工作

即時通訊使用的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 
+0

您使用的是ARC嗎?你可以在fadeAndShow方法的開始處添加NSLog(@「Images count =%d」,[images count])併發布它嗎? – giorashc 2013-03-20 08:07:41

+0

Arc Xcode 3?當然不。 Vlad如果你使用這些版本的版本與本書的版本相同,但如果你打算實際發佈一個應用程序,你最終必須升級xcode。 – LearnCocos2D 2013-03-20 09:23:28

回答

0

這裏的回答:

[[CCDirector sharedDirector] replaceScene: [CCTransitionZoomFlipAngular 
    transitionWithDuration:2 
    scene:[GameScene node] 
    orientation:kOrientationLeftOver]];