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.

有帮助吗?

解决方案

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
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top