Search code examples
androidcocos2d-x

Cocos2d-x Director replaceScene with Transition


i m using cocos2d-x version 3.2 and can't use Transition with animation between two scene.

ndk-stack show this error :

 cocos2d::Scheduler::unscheduleAllForTarget(void*)+55

caused in this Class CCScheduler.cpp (Line 534)

 HASH_FIND_PTR(_hashForTimers, &target, element);

is this a know issue ? or maybe i m doing some thing wrong in my code ?

thanks


class FirstScene : public Scene {    
....
scene()...
init(){
auto overlay = NodeInFirstScene::create();
this->addChild(overlay);
}
}

Overlay

Class NodeInFirstScene : public Node {
void NodeInScene1::ButtonPressed() {
Director::sharedDirector()->replace(TransitionFade::create(1.2,SecondScene::scene());
}
}

SecondScene

Class SecondScene : public Scene {
//
scene()....
init()...
}

if i use

 Director::sharedDirector()->pushScene it work fine !! 

Solution

  • i resolve it,

    First : Add method in header :

    virtual void release();
    virtual void onExit(); //
    

    Second : Release any objects inside my custom class.

    CC_SAFE_RELEASE(mObject);
    unscheduleAllSelectors();
    ...
    

    Voila,