This commit is contained in:
parent
98a2014037
commit
ee30817b75
5 changed files with 34 additions and 20 deletions
|
@ -110,3 +110,9 @@ void CGameScene::think(int _frames)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
int CGameScene::readyToShutdown()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
|
@ -18,11 +18,12 @@ public:
|
||||||
virtual ~CGameScene() {;}
|
virtual ~CGameScene() {;}
|
||||||
|
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
void shutdown();
|
void shutdown();
|
||||||
void render();
|
void render();
|
||||||
void think(int _frames);
|
void think(int _frames);
|
||||||
char *getSceneName() {return "Game";}
|
int readyToShutdown();
|
||||||
|
char *getSceneName() {return "Game";}
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -36,11 +36,12 @@
|
||||||
class CPaulScene : public CScene
|
class CPaulScene : public CScene
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void init();
|
void init();
|
||||||
void shutdown();
|
void shutdown();
|
||||||
void render();
|
void render();
|
||||||
void think(int _frames);
|
void think(int _frames);
|
||||||
char *getSceneName() {return"PaulsScene";}
|
int readyToShutdown() {return false;}
|
||||||
|
char *getSceneName() {return"PaulsScene";}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -46,21 +46,26 @@ void GameState::think()
|
||||||
{
|
{
|
||||||
updateTimer();
|
updateTimer();
|
||||||
|
|
||||||
if( s_pendingScene )
|
|
||||||
|
if(s_pendingScene)
|
||||||
|
{
|
||||||
|
if(s_currentScene)
|
||||||
{
|
{
|
||||||
if( !s_currentScene)
|
if(s_currentScene->readyToShutdown())
|
||||||
{
|
{
|
||||||
if( s_currentScene )
|
ASSERT(s_pendingScene); // There really should be a scene pending before you shutdown..!
|
||||||
{
|
|
||||||
s_currentScene->shutdown();
|
s_currentScene->shutdown();
|
||||||
}
|
s_currentScene=NULL;
|
||||||
|
|
||||||
s_currentScene=s_pendingScene;
|
|
||||||
s_pendingScene=NULL;
|
|
||||||
|
|
||||||
s_currentScene->init();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(!s_currentScene)
|
||||||
|
{
|
||||||
|
s_currentScene=s_pendingScene;
|
||||||
|
s_currentScene->init();
|
||||||
|
s_pendingScene=NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ASSERT(s_currentScene);
|
ASSERT(s_currentScene);
|
||||||
s_currentScene->think(getFramesSinceLast());
|
s_currentScene->think(getFramesSinceLast());
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ public:
|
||||||
virtual void shutdown()=0;
|
virtual void shutdown()=0;
|
||||||
virtual void render()=0;
|
virtual void render()=0;
|
||||||
virtual void think(int _frames)=0;
|
virtual void think(int _frames)=0;
|
||||||
|
virtual int readyToShutdown()=0;
|
||||||
virtual char *getSceneName()=0;
|
virtual char *getSceneName()=0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
Loading…
Add table
Reference in a new issue