如何获取特定图像的当前Y坐标,并将其用于if语句中?Corona SDK。

在我的游戏中,当玩家越过下边界时应该死亡,我已经实现了物理效果,我想知道如何获取我的玩家当前的 Y 坐标并在 if 语句中使用它,就像这样

如果 player.y == display.contentHeight+100,则 endGame() 结束

点赞
用户4014369
用户4014369

声明下面的语句:

h=display.contentHeight

因此创建一个运行时事件监听器

local function RTListener(event)
     if player.y>h then
        endGame()
     end
 end
Runtime:addEventListener("Runtime",RTListener)

当玩家越界时,游戏就会结束。

2014-09-23 11:01:44