Coronasdk 检测Corona SDK中每个多点触控事件的X和Y

Coronasdk 检测Corona SDK中每个多点触控事件的X和Y,coronasdk,multi-touch,touch-event,Coronasdk,Multi Touch,Touch Event,在Corona SDK中激活多点触控后,是否有办法跟踪每次同时触控的x和y坐标? 理想的函数如下: 本地功能检测多点触控(触控) 当i=0时,#触按不做 打印(触摸[i].x....触摸[i].y) 结束 结束您可以试试这个 system.activate("multitouch") local touches = {} local touchIDs = {} local function detectMultitouch() for i = 1, #touchIDs do

在Corona SDK中激活多点触控后,是否有办法跟踪每次同时触控的x和y坐标?
理想的函数如下:
本地功能检测多点触控(触控)
当i=0时,#触按不做
打印(触摸[i].x....触摸[i].y) 结束
结束

您可以试试这个

system.activate("multitouch")

local touches = {}
local touchIDs = {}

local function detectMultitouch()
    for i = 1, #touchIDs do
        print("#"..i.." "..tostring(touchIDs[i]) .." = "..touches[touchIDs[i]].x..","..touches[touchIDs[i]].y)
    end
end

Runtime:addEventListener("touch",function(event)
    if event.phase == "began" then
        touches[event.id] = {}
        touches[event.id].x = event.x
        touches[event.id].y = event.y
        touches[event.id].coords = display.newText(tostring(event.id).." = "..touches[event.id].x..","..touches[event.id].y,0,0,system.nativeFont,15)
        touches[event.id].coords.x = touches[event.id].x
        touches[event.id].coords.y = touches[event.id].y

        table.insert(touchIDs,event.id)
    elseif event.phase == "moved" then
        touches[event.id].x = event.x
        touches[event.id].y = event.y
        touches[event.id].coords.text = tostring(event.id).." = "..touches[event.id].x..","..touches[event.id].y
        touches[event.id].coords.x = touches[event.id].x
        touches[event.id].coords.y = touches[event.id].y - 20
    elseif event.phase == "ended" then
        touches[event.id].coords:removeSelf()
        touches[event.id] = nil
        table.remove(touchIDs,table.indexOf(touchIDs, event.id))


        detectMultitouch(touches)
    end
end)

您想在哪里使用多点触摸?