Page 1 of 1

[RESOLVED] Detecting when key is not being pressed anymore

Posted: Thu Jun 06, 2013 9:33 am
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.

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

Posted: Thu Jun 06, 2013 12:05 pm
by Boolsheet

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

Posted: Thu Jun 06, 2013 2:46 pm
by Nife
Boolsheet wrote:See the love.joystickpressed and love.joystickreleased callbacks.
Worked like a charm, thank you very much!

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

Posted: Fri Jun 07, 2013 8:01 am
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.

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

Posted: Fri Jun 07, 2013 8:47 am
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.

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

Posted: Sun Jun 09, 2013 9:19 am
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.