keyboard.isDown help
Posted: Sat Apr 22, 2017 3:59 pm
I have this code:
if love.keyboard.isDown('b') then
if playerRotated == false then
player.width = player.width * 2;
player.height = player.height / 2;
playerRotated = true;
else
player.width = player.width / 2;
player.height = player.height * 2;
playerRotated = false;
end
end
Which rotates a rectangle back and forth. How I do I make it so that instead of it cycling through rotations a million times while the B button is down, it will register b as being pressed only once even if it is being held down? That way it cycles through a rotation once, since you've only pressed b once?
if love.keyboard.isDown('b') then
if playerRotated == false then
player.width = player.width * 2;
player.height = player.height / 2;
playerRotated = true;
else
player.width = player.width / 2;
player.height = player.height * 2;
playerRotated = false;
end
end
Which rotates a rectangle back and forth. How I do I make it so that instead of it cycling through rotations a million times while the B button is down, it will register b as being pressed only once even if it is being held down? That way it cycles through a rotation once, since you've only pressed b once?