我试图允许在我的游戏中暂停。目前,我有一个很好的改变状态。对于暂停我有:游戏状态管理器,暂停和恢复
void PushState(int newState)
{
pauseID = stateID; ///save state number
Gstates.push_back(currentState); ///Set Current state to vector
nextState = newState; ///acquire new state
switch(nextState)
{
case STATE_INTRO:
currentState = new CIntroState(); ///create new state
break;
}
//Change the current state ID
stateID = nextState;
//NULL the next state ID
nextState = STATE_NULL;
}
以上部分似乎工作正常。
这是我的简历部分
void Resuming()
{
nextState = pauseID;
if(nextState != STATE_EXIT)
{
delete currentState; ///deletes current state
}
switch(nextState)
{
case STATE_INTRO:
currentState = Gstates.back(); ///sets current state to the saved state
Gstates.pop_back(); ///delets saved state
break;
}
//Change the current state ID
stateID = nextState;
//NULL the next state ID
nextState = STATE_NULL;
}
我得到一些奇怪的多线程错误。大约50%的时间是按预期的方式工作的,但其余的时间都是崩溃的。
误差基本上说,“这很可能是一个多线程的客户端和XInitThreads没有被调用
客户端是不是多线程;)..总之,没有任何人有任何想法是怎么回事?在
http://tronche.com/gui/x/xlib/display/XInitThreads.html – Saqlain 2013-03-01 18:12:38