私は cocos2d 3.x と Xcode 5.1.1 で作業しています。2 つの画像 image1.png と image2.png があります。私のゲームでは、デフォルトの画像 (スプラッシュ スクリーン) を私の画像 (image1.png) に変更しています).ここでは、image1.png を 2 秒間表示し、image2.png を次の 3 秒間、ゲームのスプラッシュ スクリーンとして表示する必要があります...よろしくお願いします..
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 に答える