SFML community forums
Help => General => Topic started by: Battleapple on January 04, 2014, 04:57:12 pm
-
To switch between a splash,a title and a menu screen i wanted to use switch with an integer.If the space key would have been pressed,the int value would be increased:
int Screen;
while (window.isOpen())
{
Event event;
while (window.pollEvent(event))
{
if (event.type == Event::Closed){ window.close(); }
}
if(Keyboard::isKeyPressed(Keyboard::Space)){Screen+1;}
window.clear();
switch (Screen)
{
case 0:
window.draw(Sp_Splash);
break;
case 1:
window.draw(Sp_Title);
break;
default:
break;
}
window.display();
}
But when i press space nothing happens(the Screen does not change).
Does anyone know why?
-
You should start learning basic C++ :)
1. Your keyboard checks have to be inside the while statement.
2. Screen + 1 does nothing. Either do ++Screen; or Screen = Screen + 1;
3. Learn C++ before you start using SFML :D
-
Thank you for the first answer.To get to your other statements:
I only could use an older version of my code (since i dont have my main pc next to me right now).So i forgot to fix that +1.But honestly dont be so condenscending because i made one simple mistake.
-
You're right, I'm sorry. I jumped to conclusions to fast :)