I got a problem when I try to press the keyboard key A.
My animation stops when I hold down the Keyboard key A.
#include "SFML/Graphics.hpp"
#include "SFML/System.hpp"
#include "AniSprite.h"
int main()
{
sf::RenderWindow App(sf::VideoMode(640, 420,32), "Test");
sf::Image Image;
if (!Image.LoadFromFile("untitled1.bmp"))
return 1;
Image.CreateMaskFromColor(sf::Color::Black);
sf::Texture Texture;
Texture.LoadFromImage(Image);
AniSprite Sprite(Texture,93,96);
Sprite.SetLoopSpeed(0.007); //60 fps
while(App.IsOpened())
{
sf::Event Event;
while (App.PollEvent(Event))
{
if (Event.Type == sf::Event::Closed)
App.Close();
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Keyboard::A))
Sprite.Play();
else if ((Event.Type == sf::Event::KeyReleased) && (Event.Key.Code == sf::Keyboard::A))
Sprite.Stop();
}
App.Clear();
Sprite.Update();
App.Draw(Sprite);
App.Display();
}
}