Last active
November 18, 2015 04:11
-
-
Save thepoho/74d01fa1ca7a5f6e2b56 to your computer and use it in GitHub Desktop.
Gameshow States
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GameShowStateBase *m_currState; | |
GameShowStateBase *m_nextState; | |
GameShow::SetNextState(GameShowStateBase *pNextState) | |
{ | |
m_nextState = *pNextState; | |
} | |
GameShow::ChangeState(GameShowStateBase *pNextState) | |
{ | |
if(null != m_currState) | |
{ | |
m_currState->Close(); | |
delete m_currState; | |
m_currState = null; | |
} | |
m_currState = pNextState; | |
if(null != m_currState) | |
{ | |
m_currState->Open(); | |
} | |
} | |
GameShow::UpdateState(delta) | |
{ | |
if(m_nextState != m_currState) | |
{ | |
ChangeState(m_nextState); | |
} | |
if(null != m_currState) | |
{ | |
m_currState->Update(delta); | |
} | |
} | |
GameShow::Update(float delta) | |
{ | |
UpdateState(delta); | |
} | |
Usage SetNextState(new GameShowStateDebug()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment