1

I'm working with the cocos2d 3.x and Xcode 5.1.1.I'm having two images image1.png and image2.png.In my game i already change the default image (splash screen) to my image(image1.png).Here i need to display image1.png for 2 seconds and the image2.png to display for next 3 seconds as a splash screen of my game...Thanks in advance..

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
Prabakaran
  • 258
  • 2
  • 14
  • 2
    wow, lots of upvotes for an unclear question ! what is 'first image' to 'second image' to 'splash screen' to 'default image' .... are they related somehow ??? in which circumstances do you need what to display 2 seconds, and which circumstances do you need another texture to display 3 seconds? – YvesLeBorg Sep 22 '14 at 15:15

1 Answers1

2

This is how i do this (to fade in and out a logo, after the default image has been served by iOS. I have a SplashLogo class (a scene). It is my startup scene, it puts up the logo, fades it out, then replaces itself as the running scene with my game controller.

- (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];

}

and in AppDelegate :

- (CCScene *)startScene {
    // This method should return the very first scene to be run when your app starts.
    return [SplashLogo scene];
} 
YvesLeBorg
  • 9,070
  • 8
  • 35
  • 48