so here's the spiel,
In my Game i have a function that acts like a regular game loop to play a cutscene video, In it i read in events to know if the user has pressed the escape key, if so, i exit out of the cutscene and begin the real game loop. however, while watching the movie, sometimes it will randomly exit, and go to the normal game loop, i put a cout, in the Event when its suppose to be fired, and sure enough, when it exits randomly, the cout' is printed.
which is weird because my hand is nowhere near the Escape key.
Is this a known issue or am i doing something stupid?
the codez
//Play fullscreened Cutscene
bool MoviePlayer::playCutscene(sf::RenderWindow *rendow, MovieClip *cutscene, bool player_control, sf::Key::Code escKey)
{
if(!cutscene->isValid() )
{
return false;
}
bool run_cutscene = true;
cutscene->Loop(false);
cutscene->SetOrigin(0,0);
cutscene->SetPosition(0, 0);
while (run_cutscene)
{
// Process events
sf::Event Event;
while (rendow->GetEvent(Event))
{
//Exit if the close button is pressed
if (Event.Type == sf::Event::Closed)
{
rendow->Close();
run_cutscene = false;
}
//The Problem! this gets called randomly sometimes
if(Event.Key.Code == escKey)
{
cout << "Escaped Cutscene!\n";
run_cutscene = false;
}
}//End of Events
cutscene->Resize(rendow->GetWidth(), rendow->GetHeight());
//Update images and sound
cutscene->Update( rendow->GetFrameTime() );
//if finsished, exit cutscene
if(cutscene->isFinished())
{
run_cutscene = false;
}
//Draw the cutscenes
rendow->Clear();
cutscene->Draw(rendow);
rendow->Display();
}//End ov While loop
return cutscene->isFinished();
}//EoF
any ideas?
also, the problem is also in the main game loop, I've known about this problem for a while, but have finally decided to deal with it now so my cutscene system is finalized