【问题标题】:Image won't move in Lua LÖVE game图像在 Lua LÖVE 游戏中不会移动
【发布时间】:2013-04-21 16:25:32
【问题描述】:

我正在 Lua LÖVE 框架中为 LudumDare26 编写游戏。我似乎无法弄清楚为什么当我按下 WASD 时我的“播放器”不会移动。

function love.draw()

    playerX = 10
    playerY = 10

    if love.keyboard.isDown ("w") then
        playerY = playerY - 1
    elseif love.keyboard.isDown ("s") then
        playerY = playerY + 1
    elseif love.keyboard.isDown ("a") then
        playerX = playerX - 1
    elseif love.keyboard.isDown ("d") then
        playerX = playerX + 1
    end

    local x = love.mouse.getX()
    local y = love.mouse.getY()

    love.graphics.setColor(0, 200, 255, 100)
    love.graphics.rectangle("fill", 0, 0, 800, 300)

    love.graphics.setColor(255, 255, 255, 255)
    love.graphics.rectangle("fill", xCloud, 128, 128, 50)

    love.graphics.setColor(50, 160, 80, 255)
    love.graphics.rectangle("fill", 0, 300, 800, 300)

    love.graphics.setColor(255, 0, 0, 255)
    love.graphics.draw(corsair, x - 16, y - 16, 0, 1, 1, 0, 0)

    love.graphics.draw(player, playerX, playerY)

    love.graphics.line(playerX, playerY, x, y)
end

【问题讨论】:

    标签: lua love2d


    【解决方案1】:

    love.draw()方法中取出这些行:

    playerX = 10
    playerY = 10
    

    【讨论】:

      猜你喜欢
      • 2013-03-31
      • 1970-01-01
      • 1970-01-01
      • 2015-12-08
      • 1970-01-01
      • 2021-06-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多