I have this code snipit... and this is working fine.. like you press the Q button the animation plays.. but I thought I would be able to use it in the do{}while() loop to make it autoplay before any pollevents are checked.
This animation is for a logo tumble at the start of the game.
Any ideas?
void SplashScreen::Show(sf::RenderWindow& rw){
_sprite.setTexture(*TextureManager::getInstance().rSplashScreen());
_sprite.setTextureRect(sf::IntRect(0,0,844,514)); //Screen
_sprite.setPosition(220,23);
initAnimation();
/*
do{
std::cout<<"Animation Tester\n";
animSign.playAnimation("FaSign");
animSign.update(frameClock.restart());
animSign.animate(_Sign);
rw.draw(_Sign);
rw.display();
}while(animSign.isPlayingAnimation());*/
sf::Event eventSplash;
while(true)
{
while(rw.pollEvent(eventSplash))
{
if ((eventSplash.type == sf::Event::KeyPressed) && (eventSplash.key.code == sf::Keyboard::Q))
{
animSign.playAnimation("FaSign");
}
}
animSign.update(frameClock.restart());
animSign.animate(_Sign);
rw.draw(_Sign);
rw.display();
}
}
If I change some of the code to this...
sf::Event eventSplash;
while(true)
{
while(rw.pollEvent(eventSplash))
{
animSign.playAnimation("FaSign");
}
animSign.update(frameClock.restart());
animSign.animate(_Sign);
rw.draw(_Sign);
rw.display();
}
Then it plays fine, but it will play form the start every time I move my mouse inside the window... if I remove the pollevent and place the it in the while loop (what I was trying to do with the do{}while() loop then nothing happens like b4..
sf::Event eventSplash;
while(true)
{
animSign.playAnimation("FaSign");
animSign.update(frameClock.restart());
animSign.animate(_Sign);
rw.draw(_Sign);
rw.display();
}