[cocos2d-x 1.x] using replaceScene after class-destroyer

you maybe replaceScene when AA Scene call B

but it occurs a problem,

we can observe calling method’s order

A::init()
A::onEnter();
A::onEnterTransitionDidFinish();
replaceScene(B);
B::init(); #1
A::A\ ();\ #2
B::onEnter();
B::onEnterTransitionDidFinish;
view\ #1,\ #2
your\ app\ will\ be\ crashed\ when\ you\ over-loaded\ to\ memory\ and\ over-loaded\ to\ memory\ in\ AA\ And\ B\ .\
we\ should\ need\ to\ solve\ via\ empty\ scene.
I\ solved\ by\ this\ problem\ by\ C++\ template.

———————LoadingScene.h———————
#pragma\ once
#include\ “cocos2d.h”
USING_NS_CC;
#define\ ReplaceScene\ ->replaceScene))
#define\ PushScene\ >pushScene))
template
class\ LoadingScene\ :\ public\ CCLayer
{
private:
virtual\ void\ onEnterTransitionDidFinish
{
CCLayer::onEnterTransitionDidFinish;
CCDirector::sharedDirector
>replaceScene);
}
public:
static\ CCScene*\ scene
{
CCScene\ *\ scene\ =\ CCScene::node;
LoadingScene*\ layer\ =\ LoadingScene::node;
scene~~>addChild;
return\ scene;
}
//\ implement\ the\ “static\ node()”\ method\ manually
LAYER_NODE_FUNC;
};

———————————————————~~
A::func
{
ReplaceScene;
}
and\ we\ observe\ method\ calling\ order.
A::init
A::onEnter;
A::onEnterTransitionDidFinish;
replaceScene;
A::A ();
B::init();
B::onEnter();
B::onEnterTransitionDidFinish();

As above we solve method sequence.

I hope you use LoadingScene.h.
I can receive your advice