mirror of https://github.com/axmolengine/axmol.git
#issue #2790: Uses Vector<Scene*> for scenesStack in CCDirector.
This commit is contained in:
parent
0091ca2b6f
commit
b0cb7c230a
|
@ -110,8 +110,7 @@ bool Director::init(void)
|
||||||
|
|
||||||
_notificationNode = nullptr;
|
_notificationNode = nullptr;
|
||||||
|
|
||||||
_scenesStack = new Array();
|
_scenesStack.reserve(15);
|
||||||
_scenesStack->initWithCapacity(15);
|
|
||||||
|
|
||||||
// projection delegate if "Custom" projection is used
|
// projection delegate if "Custom" projection is used
|
||||||
_projectionDelegate = nullptr;
|
_projectionDelegate = nullptr;
|
||||||
|
@ -164,7 +163,6 @@ Director::~Director(void)
|
||||||
|
|
||||||
CC_SAFE_RELEASE(_runningScene);
|
CC_SAFE_RELEASE(_runningScene);
|
||||||
CC_SAFE_RELEASE(_notificationNode);
|
CC_SAFE_RELEASE(_notificationNode);
|
||||||
CC_SAFE_RELEASE(_scenesStack);
|
|
||||||
CC_SAFE_RELEASE(_scheduler);
|
CC_SAFE_RELEASE(_scheduler);
|
||||||
CC_SAFE_RELEASE(_actionManager);
|
CC_SAFE_RELEASE(_actionManager);
|
||||||
CC_SAFE_RELEASE(_eventDispatcher);
|
CC_SAFE_RELEASE(_eventDispatcher);
|
||||||
|
@ -597,10 +595,10 @@ void Director::replaceScene(Scene *scene)
|
||||||
CCASSERT(_runningScene, "Use runWithScene: instead to start the director");
|
CCASSERT(_runningScene, "Use runWithScene: instead to start the director");
|
||||||
CCASSERT(scene != nullptr, "the scene should not be null");
|
CCASSERT(scene != nullptr, "the scene should not be null");
|
||||||
|
|
||||||
unsigned int index = _scenesStack->count();
|
int index = _scenesStack.size();
|
||||||
|
|
||||||
_sendCleanupToScene = true;
|
_sendCleanupToScene = true;
|
||||||
_scenesStack->replaceObjectAtIndex(index - 1, scene);
|
_scenesStack.replace(index - 1, scene);
|
||||||
|
|
||||||
_nextScene = scene;
|
_nextScene = scene;
|
||||||
}
|
}
|
||||||
|
@ -611,7 +609,7 @@ void Director::pushScene(Scene *scene)
|
||||||
|
|
||||||
_sendCleanupToScene = false;
|
_sendCleanupToScene = false;
|
||||||
|
|
||||||
_scenesStack->addObject(scene);
|
_scenesStack.pushBack(scene);
|
||||||
_nextScene = scene;
|
_nextScene = scene;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -619,8 +617,8 @@ void Director::popScene(void)
|
||||||
{
|
{
|
||||||
CCASSERT(_runningScene != nullptr, "running scene should not null");
|
CCASSERT(_runningScene != nullptr, "running scene should not null");
|
||||||
|
|
||||||
_scenesStack->removeLastObject();
|
_scenesStack.popBack();
|
||||||
unsigned int c = _scenesStack->count();
|
int c = _scenesStack.size();
|
||||||
|
|
||||||
if (c == 0)
|
if (c == 0)
|
||||||
{
|
{
|
||||||
|
@ -629,7 +627,7 @@ void Director::popScene(void)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_sendCleanupToScene = true;
|
_sendCleanupToScene = true;
|
||||||
_nextScene = (Scene*)_scenesStack->getObjectAtIndex(c - 1);
|
_nextScene = _scenesStack.at(c - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -641,7 +639,7 @@ void Director::popToRootScene(void)
|
||||||
void Director::popToSceneStackLevel(int level)
|
void Director::popToSceneStackLevel(int level)
|
||||||
{
|
{
|
||||||
CCASSERT(_runningScene != nullptr, "A running Scene is needed");
|
CCASSERT(_runningScene != nullptr, "A running Scene is needed");
|
||||||
int c = static_cast<int>(_scenesStack->count());
|
int c = _scenesStack.size();
|
||||||
|
|
||||||
// level 0? -> end
|
// level 0? -> end
|
||||||
if (level == 0)
|
if (level == 0)
|
||||||
|
@ -657,7 +655,7 @@ void Director::popToSceneStackLevel(int level)
|
||||||
// pop stack until reaching desired level
|
// pop stack until reaching desired level
|
||||||
while (c > level)
|
while (c > level)
|
||||||
{
|
{
|
||||||
Scene *current = (Scene*)_scenesStack->getLastObject();
|
auto current = _scenesStack.back();
|
||||||
|
|
||||||
if (current->isRunning())
|
if (current->isRunning())
|
||||||
{
|
{
|
||||||
|
@ -666,11 +664,11 @@ void Director::popToSceneStackLevel(int level)
|
||||||
}
|
}
|
||||||
|
|
||||||
current->cleanup();
|
current->cleanup();
|
||||||
_scenesStack->removeLastObject();
|
_scenesStack.popBack();
|
||||||
--c;
|
--c;
|
||||||
}
|
}
|
||||||
|
|
||||||
_nextScene = (Scene*)_scenesStack->getLastObject();
|
_nextScene = _scenesStack.back();
|
||||||
_sendCleanupToScene = false;
|
_sendCleanupToScene = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -701,7 +699,7 @@ void Director::purgeDirector()
|
||||||
|
|
||||||
// remove all objects, but don't release it.
|
// remove all objects, but don't release it.
|
||||||
// runWithScene might be executed after 'end'.
|
// runWithScene might be executed after 'end'.
|
||||||
_scenesStack->removeAllObjects();
|
_scenesStack.clear();
|
||||||
|
|
||||||
stopAnimation();
|
stopAnimation();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue