bool StateManager::update(size_t dt) { if (m_bNeedDestroy) { IState* st = m_States.top(); st->destroy(); delete st; m_States.pop(); m_bNeedDestroy = false; return true; } if (m_newState != 0) { m_States.push(m_newState); m_newState = 0; return true; } if (m_States.empty()) return false; if (m_bNeedInit) { m_States.top()->init(); m_bNeedInit = false; return true; } m_States.top()->update(dt); m_States.top()->render(); return true; }
void StateManager::destroy() { for (size_t i = 0; i != eState_Size; ++i) { IState* s = states_[i]; if (s) { s->destroy(); delete s; states_[i] = 0; } } }