如何在Corona中检测手指滑离触摸显示屏的时间

时间:2012-01-19 17:56:48

标签: events touch corona

对于Corona sdk,如何检测手指何时从显示屏上滑落? Corona在模拟器上运行的示例代码“dragme”允许您的手指(指针)从屏幕上拖出并再次打开并继续监控手指的位置,因此我无法从中学到任何东西。

1 个答案:

答案 0 :(得分:0)

我们可以这样做吗? 使用运行时监听器使用display.viewableContentWidth / Height检查“边界”上的“移动”触摸事件?

local xMin = (display.viewableWidth-display.viewableContentWidth)/2
local xMax = xMin+display.viewableContentWidth
local yMin = (display.viewableHeight-display.viewableContentHeight)/2
local yMax = yMin+display.viewableContentHeight
Runtime:addEventListener("touch",function()
  if event.phase == "moved" then
    if event.x < xMin or event.x > xMax or 
         event.y < yMin or event.y > yMax then

         --do something
    end
  end
end
相关问题