ex:
sf::RenderWindow mywindow(sf::VideoMode(800,600,32),"test");
sf::Event ev;
void world1();
int main()
{
while(mywindow.isOpen())
{
while(mywindow.pollEvent(ev))
{
switch(ev.type)
{
case sf::Event::Closed:
mywindow.close();
case sf::Event::KeyPressed:
if(ev.key.code == sf::Keyboard::Space)
world1();
}
}
mywindow.clear(sf::Color(0,200,0));
mywindow.display();
}
}
void world1()
{
bool go = true;
while(go)
{
while(mywindow.pollEvent(ev))
{
switch(ev.type)
{
case sf::Event::KeyPressed:
if(ev.key.code == sf::Keyboard::Left)
go = false;
}
mywindow.clear(sf::Color(200,0,0));
mywindow.display();
}
}
}
here, the ev variable is polled by two different pollevents, deppending on where the loop is executing, is that okay?