raidho36 wrote: ↑Sat Feb 17, 2018 12:05 pm
LÖVE mainly handles input via events, the "isDown" is for quick and dirty hacks mid-development and you shouldn't rely on it.
I don't know, I see that the most in other people's finished source code. It's even used in Mari0 the most well known Love2d game.
Be aware that Maurice (its dev) did state that mari0's source is pretty much hacked together... although i guess you could ask him on Discord since i really don't want to say things in others' stead;
that said, if there's a good enough reason to, using isDown isn't hacky at all; one such reason is implementing a multi-state key detection lib, for example; you couldn't detect held keys without the isDown function that way, nor ones that are currently "idle".
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
raidho36 wrote: ↑Sat Feb 17, 2018 12:05 pm
LÖVE mainly handles input via events, the "isDown" is for quick and dirty hacks mid-development and you shouldn't rely on it.
I don't know, I see that the most in other people's finished source code. It's even used in Mari0 the most well known Love2d game.
Be aware that Maurice (its dev) did state that mari0's source is pretty much hacked together... although i guess you could ask him on Discord since i really don't want to say things in others' stead;
that said, if there's a good enough reason to, using isDown isn't hacky at all; one such reason is implementing a multi-state key detection lib, for example; you couldn't detect held keys without the isDown function that way, nor ones that are currently "idle".
When I said 'even used in Mari0' I actually didn't mean 'only used in Mari0'. It's even used in Kikito's bump demos and his Kongame. You're right it's not hacky at all and it's what I see mainly used for movement control.
Tjakka5 wrote: ↑Fri Feb 16, 2018 6:46 pm
Besides that, you should not base your game's behavior around keypressed repeating. The delay between repeats can differ from os to os, and may even be customized in some environments.
If you want your player to be able to be constantly jumping while holding the up key, you should instead be using love.keyboard.isDown.
Last but not least, to fix your "defining multiple callbacks" problem, you want to propagate events if they are not satisfied.
For example, when you click on screen you first want to tell your UI code there was a keypress.
It will return true if it "used" it, or false if it didn't click on anything.
If it returns false you can then propagate it to the next system, and the next and the next.