lolyoshi
lolyoshi

Reputation: 1546

Change scene after few seconds in Cocos2d-x

I'm a newbie. At this time, I want to change scene after a few seconds (about 3-5 seconds). But I don't know how to do. I know schedule but I don't want it loops. I mean it just works only once.

Thanks!

Upvotes: 0

Views: 2430

Answers (3)

Arsalan
Arsalan

Reputation: 170

You can use this this->scheduleOnce(<#SEL_SCHEDULE selector#>, <#float delay#>). This way you can acheive what you want.

Upvotes: 0

user1474142
user1474142

Reputation: 124

For example, running a main menu scene after a 2.0s delay from the splash screen.

// In the init()
this->schedule(schedule_selector(CSplashLayer::RunMainMenu), 2.0f);

// function in the splash layer class
void CSplashLayer::RunMainMenu(float dt) {
  // tell CCDirector to run main menu
}

Upvotes: 4

Singhak
Singhak

Reputation: 8906

You can do like this

CCScene *pScene = GameLayer::scene();
CCTransitionPageTurn *crosssfade = CCTransitionPageTurn::create(3,pScene, true);
CCDirector::sharedDirector()->replaceScene(crosssfade);

You can use any Transition effect to change the scene with any time to take this transition to complete

Upvotes: 0

Related Questions