Corona SDK - 事件 "touch",阶段 "moved" - 检测当前是否在对象上方

Corona SDK - event "touch", phase "moved" - detect if currently over an object

例如,我绘制了几个静态圆圈(或其他一些对象),并调用了它们

circle:addEventListener("touch", onTouch)

他们所有人。

onTouch 函数内部有没有简单的方法来判断新的触摸坐标是否在另一个对象上?

local function onTouch(event)
    local c = event.target
    local phase = event.phase
    if (phase == "moved") then
        -- HERE
        -- I would like to receive a pointer to the object I'm hovering over
    end
    return true  -- Prevents touch propagation to underlying objects
end

保存对 table circles 中显示对象的引用。接下来,在 moved 阶段的 onTouch 函数中迭代 table circles 中的项目以找到您悬停的对象。您可以使用 属性 object.contentBounds 在内容坐标中查找对象的边界。