0
local held = false
local function jumperTap()
jumper:applyForce(0, 200, jumper.x, jumper.y)
return false
end
Runtime:addEventListener("tap", jumperTap)
local function holdListener(event)
held = true
jumper:applyForce(0, 250, jumper.x, jumper.y )
return true
end
local function jumperTouch(event)
if (event.phase == "began") then
display.getCurrentStage():setFocus(jumper)
holdTimer = timer.performWithDelay(500, holdListener)
elseif (event.phase == "moved") then
timer.cancel(holdTimer)
elseif (event.phase == "ended" or event.phase == "cancelled") then
display.getCurrentStage():setFocus(nil)
timer.cancel(holdTimer)
held = false
end
end
Runtime:addEventListener("touch", jumperTouch)
我正在嘗試點擊和觸摸並按住。當觸摸和握住發生時,跳投將施加更多的力量,以便在觸摸和握住屏幕時他可以跳得更高。當輕擊屏幕時,他將跳躍較短。Corona SDK:Tap和Touch +毛刺
當我點擊時,會發生預期的事情。當我點擊並按住時,會發生預期的事情。由於我在科羅納的新手,我確實有一些明顯的問題。他們是...
-當我點擊並按住,一切順利,但是當我釋放,它會出現毛刺和執行什麼似乎是一個龍頭事件。不知道爲什麼會這樣
-當我執行敲打事件,我能當物體在空氣中再次執行它 - 這使他倒在地上,並敲打事件似乎再次執行,但力量較小。
任何和所有的幫助,非常感謝!
編輯:我把返回true和返回false只是爲了嘗試不同的東西,但它並沒有影響任何東西。