is there a touch and hold event in Corona sdk, If not then how to do that. for example. i want to increase the radius of a circle while holding anywhere on the screen, and without moving. how to do that. '
thanx
Try (as I know you can't change radius so I use xScale
and yScale
to increase circle)
local circle = display.newCircle( display.contentCenterX, display.contentCenterY, 50 )
step = 0.02
local holding = false
local function enterFrameListener()
if holding then
-- Holding button
circle.xScale = circle.xScale + step
circle.yScale = circle.yScale + step
else
-- Not holding
-- Code here
end
end
local function touchHandler( event )
if event.phase == "began" then
Runtime:addEventListener( "enterFrame", enterFrameListener )
holding = true
elseif event.phase == "ended" or event.phase == "moved" then
holding = false
Runtime:removeEventListener( "enterFrame", enterFrameListener )
end
return true
end
Runtime:addEventListener( "touch", touchHandler )
The code borrow from post from stackoverflow.com.