class Game
{
public:
static void Start();
private:
static bool IsExiting();
static void GameLoop();
static void ShowSplashScreen();
static void ShowMenu();
enum GameState { Uninitialized, ShowingSplash, Paused,
ShowingMenu, Playing, Exiting };
Game::GameState Game::_gameState = Game::Uninitialized;
static sf::RenderWindow _mainWindow;
};
Game::GameState Game::_gameState;
RenderWindow Game::_mainWindow;
错误现在在首先运行的函数中
void processEvents(){// error: first defined here ???
Event event;
while(App.pollEvent(event)){
if(event.type == Event::Closed)
App.close();
}
}
还有其他错误,例如在函数中定义了多个 `Game::_gameState' 它在 Game 类中声明的其他函数中给出了相同的错误
void Game::Start(void) { // multiple definition of `Game::_gameState'
if (_gameState != Uninitialized)
return;
_mainWindow.create(VideoMode(1200, 900, 32), "Game",
Style::Close);
_gameState = Game::ShowingSplash;
while (!IsExiting()) {
GameLoop();
}
_mainWindow.close();
}
我修复了错误,但又出现了一个
while (!IsExiting()) { //undefined reference to Game::IsExiting
GameLoop();
}
_mainWindow.close();
}
我不知道它是静态 bool 函数,其他函数可以正常工作,但这个是 bool 并给我错误