Hi!
I started to build a simple computer game (in 2D) with C++ and SFML.
And I got this error:
Error 1 error C2039: 'GetEvent' : is not a member of 'sf::RenderWindow' Someone can explain me what I wrote wrong?
(the error in game.cpp where I wrote "//her the error"
This is my files:
game.h
#pragma once
#include "SFML/Window.hpp"
#include "SFML/Graphics.hpp"
class Game
{
public:
static void Start();
private:
static bool IsExiting();
static void GameLoop();
enum GameState { Uninitialized, ShowingSplash, Paused, ShowingMenu, Playing, Exiting };
static GameState _gameState;
static sf::RenderWindow _mainWindow;
};
game.cpp
#include "stdafx.h"
#include "Game.h"
void Game::Start(void)
{
if(_gameState != Uninitialized)
{
return;
}
_mainWindow.create(sf::VideoMode(1024, 768, 32), "Pang!");
_gameState = Game::Playing;
while(!IsExiting())
{
GameLoop();
}
_mainWindow.close();
}
bool Game::IsExiting()
{
if(_gameState == Game::Exiting)
{
return true;
}
else
{
return false;
}
}
void Game::GameLoop()
{
sf::Event currentEvent;
while(_mainWindow.GetEvent(currentEvent)) //her the error
{
switch(_gameState)
{
case Game::Playing:
{
_mainWindow.clear(sf::color(255,0,0));
_mainWindow.Display();
if(currentEvent.type == sf::Event::Closed)
{
_gameState = Game::Exiting;
}
break;
}
}
}
}
Game::GameState Game::_gameState = Uninitialized;
sf::RenderWindow Game::_mainWindow;