我正在使用 cocos2d 3.x 和 Xcode 5.1.1。我有两个图像 image1.png 和 image2.png。在我的游戏中,我已经将默认图像(启动画面)更改为我的图像(image1.png ).这里我需要显示 image1.png 2 秒和 image2.png 显示接下来的 3 秒作为我的游戏的启动画面...提前谢谢..
问问题
299 次
1 回答
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];
}
于 2014-09-22T16:23:10.800 回答