void doTransition(String gsName) { if (myStateStack.Count > 0) { if (gsName == myStateStack.Peek().name) { return; } GameState oldState = myStateStack.Pop(); if (oldState != null) { oldState.onExit(); } } GameState newState; if (myGameStates.TryGetValue(gsName, out newState) == false) { throw new Exception("Unknown state " + gsName); } newState.onEnter(); myStateStack.Push(newState); }
public void pop() { if (state != null) { state.onExit(); Game.instance().getWindow().clean(); state = null; } }
public void doPop() { if (myStateStack.Count == 0) { throw new Exception("Cannot pop an empty game state stack"); } GameState gs = myStateStack.Pop(); gs.onExit(); }