Today’s post is really short, but it’s essential. Corona SDK has a built in feature to detect double tabs. This double tap feature can be used for jumping, shooting, and so much more. Here’s the code!
local player = display.newRect(0, 0, 250, 250)
player.strokeWidth = 3
player:setFillColor(140, 140, 140)
player:setStrokeColor(180, 180, 180)
player.x = display.contentWidth/2
player.y = display.contentHeight/2
function player:tap( event )
if (event.numTaps >= 2 ) then
print( "The object was double-tapped." )
return true;
elseif (event.numTaps == 1 ) then
print("The object was tapped once.")
end
end
player:addEventListener( "tap" )