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?
keyboard.isDown help
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- Sir_Silver
- Party member
- Posts: 286
- Joined: Mon Aug 22, 2016 2:25 pm
- Contact:
Re: keyboard.isDown help
You want to use the keypressed callback instead of the isDown function.
Code: Select all
function love.keypressed(key)
--Your code here
end
Who is online
Users browsing this forum: Amazon [Bot] and 3 guests