boipushy (Input handling)
Re: [Library] boipushy (Input handling)
Maybe you're still calling input:update()? In the new version you shouldn't call it because it's implicit. So if you call it will happen twice (your call and the implicit one)
Re: [Library] boipushy (Input handling)
Thank you! That was the problem.adnzzzzZ wrote:Maybe you're still calling input:update()? In the new version you shouldn't call it because it's implicit. So if you call it will happen twice (your call and the implicit one)
Re: [Library] boipushy (Input handling)
Is it just me or this library's pressed/released functions stopped working in this new LOVE update?
I'm trying to fix it, but not so lucky so far.
I'm trying to fix it, but not so lucky so far.
Re: [Library] boipushy (Input handling)
I updated this library with a new function: pressRepeat. This function allows you to trigger events on an interval if a key is held down, instead of it doing it every frame. So this:
Will print a random number to the console every 0.5 seconds from when left click is held down. You can see more about the library here:
boipushy
Code: Select all
function love.load()
input:bind('mouse1', 'some_action')
end
function love.update(dt)
if input:pressRepeat('some_action', 0.5) then print(love.math.random()) end
end
boipushy
Re: boipushy (Input handling)
Neat little library, I like it.
A note about gamepad handling, love makes use of the SDL_GameControllerDB, however the version they ship with is only updated whenever a new version of love comes out. Normally this isn't a problem, but it you want to be as up-to-date as possible (or allow players to manually update it), use something to this effect:
A note about gamepad handling, love makes use of the SDL_GameControllerDB, however the version they ship with is only updated whenever a new version of love comes out. Normally this isn't a problem, but it you want to be as up-to-date as possible (or allow players to manually update it), use something to this effect:
Code: Select all
pcall(love.joystick.loadGamepadMappings, 'gamecontrollerdb.txt')
- slime
- Solid Snayke
- Posts: 3162
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: boipushy (Input handling)
We don't actually ship with that database. SDL has an internal list it uses, and that database is someone else's (useful) list of extra devices that aren't necessarily in SDL's list.
Re: boipushy (Input handling)
I updated this with better explanations on the page and also a new function called sequence. The sequence function allows you to check for sequences of buttons pressed within an interval of each other. For instance:
In the example above the sequence function will return true when the 'right' action is pressed twice, and the second key press happened within 0.5s of the first. This is useful for simple things like dashing, but also for more complex sequences like combos. This function must be started and finished with an action, and between each action there should be the interval limit.
boipushy
Code: Select all
function love.update(dt)
if input:sequence('right', 0.5, 'right') then
-- dash right
end
end
boipushy
-
- Prole
- Posts: 3
- Joined: Fri Mar 23, 2018 5:32 am
Re: boipushy (Input handling)
I am playing with boipushy and when i try delay, interval or sequence features events are called immediatly
is there something i missed to enable those features?
i wrote it like in documentation:
this print in my console "f" every update , same for sequence it print "sequence a" even if pressed a one time
is there something i missed to enable those features?
i wrote it like in documentation:
Code: Select all
if game.playerController.input:down('f', 100) then
print('f')
end
Code: Select all
if game.playerController.input:sequence('a', 0.5, 'a') then
print('sequence a')
end
- radgeRayden
- Prole
- Posts: 29
- Joined: Sun Jul 27, 2014 6:49 pm
- Location: Brasil
- Contact:
Re: boipushy (Input handling)
Hello, for some reason this is failing for me:
I added the prints for debug purposes, I get the "stop right" every frame when holding 'walk_left'. I'm not sure if my code is at fault here. If I hold walk_left or walk_right without pressing the opposite direction it works fine.
Edit: figured it out, I had my own definition of love.keyreleased in main.lua.
Code: Select all
function love.update(dt)
--[...] some irrelevant code before this
if input:pressed('walk_left') and character.deltaX > 0 then
character.deltaX = 0
print("stop left")
end
if input:pressed('walk_right') and character.deltaX < 0 then
character.deltaX = 0
print("stop right")
end
if input:down('walk_left') then
character.deltaX = character.deltaX - 30 * dt
end
if input:down('walk_right') then
character.deltaX = character.deltaX + 30 * dt
end
character.x, character.y = world:move(character, character.x + character.deltaX * dt, character.y + character.deltaY * dt) --I'm using bump
end
Edit: figured it out, I had my own definition of love.keyreleased in main.lua.
Who is online
Users browsing this forum: Google [Bot] and 1 guest