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;
Error is now in function that runs first
void processEvents(){// error: first defined here ???
Event event;
while(App.pollEvent(event)){
if(event.type == Event::Closed)
App.close();
}
}
And there are also other error such as multiple definition of `Game::_gameState’ in function it gives the same errors in other functions that are declared in Game class
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();
}
I fixed the errors but one more showed up
while (!IsExiting()) { //undefined reference to Game::IsExiting
GameLoop();
}
_mainWindow.close();
}
I don’t know it is static bool function other functions works fine but this one is bool and gives me errors
Because the
enum GameStateis contained withinclass Gameyou need to scope the variable accordingly: