I'm trying to make a simple 2D game using SFML and this tutorial. Here's to code for my current progress in the tutorial: I'm having problem with the enum EventType for class Event. Member variable name is Type.
#include "stdafx.h"
#include "SplashScreen.h"
void SplashScreen::Show(sf::RenderWindow & renderWindow)
{
sf::Image image;
if(image.LoadFromFile("images/SplashScreen.png") != true)
{
return;
}
sf::Sprite sprite(image);
renderWindow.Draw(sprite);
renderWindow.Display();
sf::Event event;
while(true)
{
while(renderWindow.GetEvent(event))
{
if( event.Type == sf::Event::EventType::KeyPressed
|| event.Type == sf::Event::EventType::MouseButtonPressed
|| event.Type == sf::Event::EventType::Closed )
{
return;
}
}
}
}
This is my stdafx.h:
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#ifndef STDAFX_H
#define STDAFX_H
#include <stdio.h>
// TODO: reference additional headers your program requires here
#include <SFML/System.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <SFML/Audio.hpp>
#include <map>
#include <iostream>
#include <cassert>
#endif //STDAFX_H
It seems it has included Event.hpp because I've autocompletation works for event. MouseButtonPressed and all the other enum values appears after sf::Event::EventType::
scope in Code Blocks. I've also checked Event.hpp file and it is correct. I don't understand why the compiler is messing with me.
When i try to remove the scopes and only write "event.Type == KeyPressed" instead the compiler says "Keypressed was not declared in this scope". I run Code Blocks 10.05 on Ubuntu 12.04.
Know what's wrong?
Edit: This is my Event.hpp
The name of the enum is not a scope. Just replace sf::Event::EventType::KeyPressed
to sf::Event::KeyPressed
.