-2

我使用http://www.dreamincode.net/forums/topic/118898-state-management/来设置我的状态和经理。尚不清楚的是,如何向所述系统添加状态?

4

1 回答 1

1

只是子类GameState,即

class MainMenuState : public GameState{
public:
  virtual void Init(){
    /* Your init code */
  }
  virtual void Cleanup(){
    /* Your cleanup code */
  }
  virtual void Pause(){
    /* Callback received when state is paused */
  }
  virtual void Resume(){
    /* Callback received when state is resumed */
  }
  virtual void GetEvents(){
    /* get events */
  }
  virtual void Update(){
    /* update */
  }
  virtual void Display(){
    /* display */
  }
};

然后您可以PushState使用新类作为参数调用您的函数:

MainMenuState menuState;
stateManager.PushState(&menuState);
于 2013-11-08T23:16:02.343 回答