Whenever i press the Left, Right, Up, or Down buttons, my sprite moves in those directions. However, when i press one of the buttons the sprite moves to that direction for one second, then it pauses and then it starts to move. Heres my movement code:
if(App.GetInput().IsKeyDown(sf::Key::Up))
{
spriteFrameUp++;
if(spriteFrameUp > 1)
Link.SetImage(linkup2);
if(spriteFrameUp > 2)
Link.SetImage(linkup3);
if(spriteFrameUp > 3)
Link.SetImage(linkup4);
if(spriteFrameUp > 4)
Link.SetImage(linkup5);
if(spriteFrameUp > 5)
Link.SetImage(linkup6);
if(spriteFrameUp > 6)
Link.SetImage(linkup7);
if(spriteFrameUp > 7)
Link.SetImage(linkup8);
if(spriteFrameUp > 8)
spriteFrameUp = 0;
Link.Move(0, -velocity);
}
if(App.GetInput().IsKeyDown(sf::Key::Down))
{
spriteFrameDown++;
if(spriteFrameDown > 1)
Link.SetImage(linkdown2);
if(spriteFrameDown > 2)
Link.SetImage(linkdown3);
if(spriteFrameDown > 3)
Link.SetImage(linkdown4);
if(spriteFrameDown > 4)
Link.SetImage(linkdown5);
if(spriteFrameDown > 5)
Link.SetImage(linkdown6);
if(spriteFrameDown > 6)
Link.SetImage(linkdown7);
if(spriteFrameDown > 7)
Link.SetImage(linkdown8);
if(spriteFrameDown > 8)
spriteFrameDown = 1;
Link.Move(0, velocity);
}
if(App.GetInput().IsKeyDown(sf::Key::Right))
{
spriteFrameRight++;
if(spriteFrameRight > 1)
Link.SetImage(linkright2);
if(spriteFrameRight > 2)
Link.SetImage(linkright3);
if(spriteFrameRight > 3)
Link.SetImage(linkright4);
if(spriteFrameRight > 4)
Link.SetImage(linkright5);
if(spriteFrameRight > 5)
Link.SetImage(linkright6);
if(spriteFrameRight > 6)
Link.SetImage(linkright7);
if(spriteFrameRight > 7)
Link.SetImage(linkright8);
if(spriteFrameRight > 8)
spriteFrameRight = 1;
Link.Move(velocity, 0);
}
if(App.GetInput().IsKeyDown(sf::Key::Left))
{
spriteFrameLeft++;
if(spriteFrameLeft > 1)
Link.SetImage(linkleft2);
if(spriteFrameLeft > 2)
Link.SetImage(linkleft3);
if(spriteFrameLeft > 3)
Link.SetImage(linkleft4);
if(spriteFrameLeft > 4)
Link.SetImage(linkleft5);
if(spriteFrameLeft > 5)
Link.SetImage(linkleft6);
if(spriteFrameLeft > 6)
Link.SetImage(linkleft7);
if(spriteFrameLeft > 7)
Link.SetImage(linkleft8);
if(spriteFrameLeft > 8)
spriteFrameLeft = 1;
Link.Move(-velocity, 0);
}