keyboard.isDown help

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Andrew4Lyf
Prole
Posts: 1
Joined: Tue Apr 18, 2017 4:11 pm

keyboard.isDown help

Post by Andrew4Lyf »

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?
User avatar
Sir_Silver
Party member
Posts: 286
Joined: Mon Aug 22, 2016 2:25 pm
Contact:

Re: keyboard.isDown help

Post by Sir_Silver »

You want to use the keypressed callback instead of the isDown function.

Code: Select all

function love.keypressed(key)
    --Your code here
end
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 2 guests