0
人が右または左にスワイプしたときに特定の機能を実行したいが、人が指を斜めにスライドさせると機能が実行されないようにしたい。これを行う簡単な方法はありますか?現在、私はこのコードで作業しています:コロナのスワイプの角度を確認する方法SDK
display.setDefault("background", 0.2, 0.2, 0.4)
local function startDrag(event)
local swipeLength = math.abs(event.x - event.xStart)
print(event.phase, swipeLength)
local t = event.target
local phase = event.phase
if "began" == phase then
return true
elseif "moved" == phase then
elseif "ended" == phase or "cancelled" == phase then
if event.xStart > event.x and swipeLength > 50 then
display.setDefault("background", 0/255,3/255, 0/255)
elseif event.xStart < event.x and swipeLength > 50 then
display.setDefault("background", 0, 0, 1)
end
end
end
local rectangle= display.newRect(100,200,1000,1000)
rectangle:setFillColor(1,1,1,0.1)
rectangle:addEventListener("touch",startDrag)
申し訳ありませんが、キーワード「then」と「end」の代わりに{}を書いています。私は今すぐJSと働いています:) –