Domanda

When using LÖVE I want to change from one menu to another by hitting the ENTER key. But I only know love.keypressed, and love.keyboard.isDown.

For those two I need to hold the button down but I only want it to be pressed once. I would appreciate any help.

È stato utile?

Soluzione

Try putting the change code in love.keyreleased()


Something like this in main.lua

local changeMenu =false

function love.draw()
    if changeMenu then 
        -- do what you need to do
        changeMenu = false
    end
end

function love.keyreleased(key)
    if key=="return" or key=="kpenter" then
        changeMenu = true
    end 
end
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top