Search code examples
cocos2d-x

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!


Solution

  • 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
    }