如何在ios中的cocos2d v3.x中设置两个不同的闪屏

时间:2014-09-22 15:11:50

标签: ios5 cocos2d-iphone cocos2d-iphone-3

我正在使用cocos2d 3.x和Xcode 5.1.1。我有两个图像image1.png和image2.png。在我的游戏中我已经更改了默认图像(启动画面)到我的图像(image1.png)。这里我需要显示image1.png 2秒和image2.png显示接下来3秒作为我游戏的启动画面...提前感谢..

1 个答案:

答案 0 :(得分:2)

这是我这样做的方式(在iOS上提供默认图像之后淡入和淡出徽标。我有一个SplashLogo类(场景)。这是我的启动场景,它会显示徽标,淡出它,然后用我的游戏控制器替换自己作为运行场景。

- (void)onEnter {

    [super onEnter];

    self.positionType = CCPositionTypePoints;
    // todo : test this background seed, GL side effects, timing, etc ...    
    // [self performSelectorInBackground:@selector(seedGameSequencer) withObject:nil];

    [self seedGameSequencer];
    CCColor     *color = [CCColor colorWithRed:0 green:0.f blue:0.f alpha:0.f];
    CCNodeColor *black = [CCNodeColor nodeWithColor:color];
    black.positionType = CCPositionTypePoints;
    black.position    = ccp(0, 0);
    black.anchorPoint = ccp(0, 0); // bottom left
    [self addChild:black];


    [GESprite mediumPixelFormat];
    CCSprite *logo = [CCSprite spriteWithImageNamed:@"maxPowerStudiosLogo.png"];
    logo.positionType = CCPositionTypePoints;
    logo.anchorPoint = ccp(.5, .5);
    logo.opacity          = 0;
    logo.positionInPoints = ccp(black.contentSizeInPoints.width / 2, black.contentSizeInPoints.height / 2);

    [GESprite defaultPixelFormat];

    id fadein          = [CCActionFadeIn actionWithDuration:3 * K_FADE_TIME];
    id taponne         = [CCActionDelay actionWithDuration:.95];
    id fadeout         = [CCActionFadeOut actionWithDuration:2 * K_FADE_TIME];
    id swapSceneAction = [CCActionCallFunc actionWithTarget:self selector:@selector(swapScene)];
    id seq             = [CCActionSequence actions:fadein, taponne, fadeout, swapSceneAction, nil];

    // add the label as a child to this Layer

    [self addChild:logo];
    [logo runAction:seq];

}

- (void)seedGameSequencer {

    mainScene = [MPGameSequencer scene];
}

- (void)swapScene {

    [[CCDirector sharedDirector] replaceScene:mainScene];

}

并在AppDelegate中:

- (CCScene *)startScene {
    // This method should return the very first scene to be run when your app starts.
    return [SplashLogo scene];
}