Corona SDK中的触摸保持事件 [英] Touch Hold Event In corona SDK
本文介绍了Corona SDK中的触摸保持事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道如何检查用户是否触摸了屏幕,但保持按下状态并且没有移动.如果您有什么我可以帮助的,请提供帮助.我一直在四处张望,至今尚未找到任何解决方法.
I was wondering how I would check if the user has touched the screen, but is holding their touch down and is not moving. Please help if you have anything I can go from. Ive been looking around and have yet to find anything to handle this.
推荐答案
您可以使用/修改此内容:(这就是Rob Miracle所说的)
You can use/modify this: (It's what Rob Miracle says)
local holding = false
local function enterFrameListener()
if holding then
-- Holding button
-- Code here
-- Code here
-- Code here
else
-- Not holding
-- Code here
-- Code here
-- Code here
end
end
local function touchHandler( event )
if event.phase == "began" then
display.getCurrentStage():setFocus( event.target )
event.target.isFocus = true
Runtime:addEventListener( "enterFrame", enterFrameListener )
holding = true
elseif event.target.isFocus then
if event.phase == "moved" then
elseif event.phase == "ended" then
holding = false
Runtime:removeEventListener( "enterFrame", enterFrameListener )
display.getCurrentStage():setFocus( nil )
event.target.isFocus = false
end
end
return true
end
我相信touchHandler函数是什么^^
I believe its obvious what touchHandler function is ^^
这篇关于Corona SDK中的触摸保持事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文