小白再提问,关于事件回调

情景如下,
一个项目,有两个场景(scene1,scene2),开始运行时运行scene1,在scene1中的某事件发生事,再运行scene2。场景的调度控件,都在AppDelegate类中完成。

bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    auto director = Director::getInstance();
    auto glview = director->getOpenGLView();
    if(!glview) {
        glview = GLViewImpl::create("My Game");
        director->setOpenGLView(glview);
    }
// turn on display FPS
    director->setDisplayStats(true);

    // set FPS. the default value is 1.0/60 if you don't call this
    director->setAnimationInterval(1.0 / 60);

    // create a scene. it's an autorelease object
    auto scene = Scene1::createScene();

    // run
    director->runWithScene(scene);
    return true;
}

现在怎么才能在scene1中的事件发生后,让AppDelegate执行director->replaceScene(scene2);

请各位大神,帮忙。

直接在scene1的回调里 调用replacescene就好了
auto scene2= Scene2::createScene();
Director::getInstance()->replaceScene(scene2);

你可以看下director 是什么来的,auto director = Director::getInstance(); 这是个单例(具体的百度下单例模式吧)

你可以在你需要的地方调用Director::getInstance()->replaceScene(scene2);

就是需要回调。
能具体点儿,举个例吗?

auto action = Sequence::create(
CallFunc::create((Ref*)this, callfunc_selector(GroundLayer::menu3movein)),delayTime,
CallFunc::create((Ref*)this, callfunc_selector(GroundLayer::menu4movein)),delayTime,
CallFunc::create((Ref*)this, callfunc_selector(GroundLayer::menu5movein)),delayTime,
CallFunc::create((Ref*)this, callfunc_selector(GroundLayer::menu6movein)),
DelayTime::create(3),
CallFunc::create((Ref*)this, callfunc_selector(GroundLayer::sendmsg)),
NULL);
runAction(action);

我用另外一种自定义事件的办法实现了。不过还是非常感谢大家。
我的方法主要用了以下的两个函数,实现了自定义事件的回调。
_eventDispatcher->addCustomEventListener
_eventDispatcher->dispatchCustomEvent