1
Graphics / Re: Gradually changing hue
« on: October 14, 2014, 12:30:53 am »
Perfect! Thank you.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Howdy, I'm trying to make a sprite animate with the Thor library when I press a key and stop animating when I release it.
This is pretty easy with event polling. I just did this:while(mainWindow.PollEvent(Event))
{
...
if((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Keyboard::Right))
animator.PlayAnimation("walk", true);
if((Event.Type == sf::Event::KeyReleased) && (Event.Key.Code == sf::Keyboard::Right))
animator.StopAnimation();
if((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Keyboard::Left))
animator.PlayAnimation("walk", true);
if((Event.Type == sf::Event::KeyReleased) && (Event.Key.Code == sf::Keyboard::Left))
animator.StopAnimation();
}
//and a thing down here that stops the animation if both keys are pressed at the same time
Unfortunately, this gets totally messed up if you happen to press both left and right at the same time, and then release one of those while still holding the other. Since no new key pressed event was fired there, the sprite will be unanimated even though a key is down (therefore my sprite is sliding along without being animated).