문제

Does the love.keyreleased(key) function the same as love.keyboard.isDown?

For example, can I declare:

function love.update()

    if love.keyreleased("left") then
            hero = heroLeft
    end
end     
도움이 되었습니까?

해결책

love.keyreleased is a callback function. It's not a function you are supposed to call. It's a function you register with the system that takes a key. The system will call it whenever a key is released.

다른 팁

No, they're not the same function.

love.keyreleased (key) is a callback function that will be called by the application whenever a key is released, therefore you may overwrite it in order to create some kind of response to the release. You are NOT supposed to call this function. Love application will deal with that for you.

love.keyboard.isDown is a love function that returns a boolean (if the key is down - true or false). You should NOT overwrite it, otherwise you won't be able to know if a key is actually down. This function can be called inside your code.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top