【问题标题】:Love2D: Stop the player from moving, when I press up or downLove2D:当我向上或向下按下时,停止播放器移动
【发布时间】:2014-12-15 02:39:22
【问题描述】:

这就是我的球员的移动方式:

if love.keyboard.isDown("right") then
    player.x = player.x + player.speed * dt
end

if love.keyboard.isDown("left") then
    player.x = player.x - player.speed * dt
end

我想做,所以当按下向上或向下按钮时,停止播放器移动。

【问题讨论】:

  • 如果答案解决了您的问题,您应该将其标记为已接受

标签: lua love2d


【解决方案1】:

您可以使用 notand 关键字将这些 if 语句包装在另一个中:

if not love.keyboard.isDown("up") and not love.keyboard.isDown("down") then
   -- Your left/right movement checks here
end

【讨论】:

    猜你喜欢
    • 2015-11-26
    • 2013-01-29
    • 2020-04-17
    • 2020-07-23
    • 2019-05-19
    • 2023-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多