[RESOLVED] Detecting when key is not being pressed anymore

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
Nife
Prole
Posts: 3
Joined: Wed Jun 05, 2013 11:15 pm

[RESOLVED] Detecting when key is not being pressed anymore

Post by Nife »

Guys, simple and dirty:

I'm using the joystick.isDown to move an object, but the detection happens extremely fast - I need a condition for when a certain key is released after being pressed.

Thanks.
Last edited by Nife on Thu Jun 06, 2013 2:47 pm, edited 1 time in total.
User avatar
Boolsheet
Inner party member
Posts: 780
Joined: Wed Dec 29, 2010 4:57 am
Location: Switzerland

Re: onRelease? Detecting when key is not being pressed anymo

Post by Boolsheet »

Shallow indentations.
Nife
Prole
Posts: 3
Joined: Wed Jun 05, 2013 11:15 pm

Re: onRelease? Detecting when key is not being pressed anymo

Post by Nife »

Boolsheet wrote:See the love.joystickpressed and love.joystickreleased callbacks.
Worked like a charm, thank you very much!
Last edited by Nife on Sun Jun 09, 2013 9:17 am, edited 1 time in total.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: onRelease? Detecting when key is not being pressed anymo

Post by Robin »

Nife wrote:Reminder to whoever happens to bump here looking for the solution:
Um, I don't think that code does what you think it does.

Here, the global variable controllerName is shadowed by the first argument to love.joystickpressed, so you can't access it inside that callback.
Help us help you: attach a .love.
User avatar
slime
Solid Snayke
Posts: 3162
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: onRelease? Detecting when key is not being pressed anymo

Post by slime »

Robin wrote:
Nife wrote:Reminder to whoever happens to bump here looking for the solution:
Um, I don't think that code does what you think it does.

Here, the global variable controllerName is shadowed by the first argument to love.joystickpressed, so you can't access it inside that callback.
Not to mention the first argument of love.joystickpressed is the joystick index, not its name.
Nife
Prole
Posts: 3
Joined: Wed Jun 05, 2013 11:15 pm

Re: onRelease? Detecting when key is not being pressed anymo

Post by Nife »

Robin wrote:Um, I don't think that code does what you think it does.
You are right, my apologies for that - removed that bit of stupidity from the post.
Post Reply

Who is online

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