Skip to content

Instantly share code, notes, and snippets.

@thepoho
Last active November 18, 2015 04:11
Show Gist options
  • Save thepoho/74d01fa1ca7a5f6e2b56 to your computer and use it in GitHub Desktop.
Save thepoho/74d01fa1ca7a5f6e2b56 to your computer and use it in GitHub Desktop.
Gameshow States
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