Corona SDK and other Game Development Tutorials
@gamebuilding

Using Double Tap in Corona SDK

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" )

If you would like to follow me on Twitter, you can follow me at Twitter.com/thatssopanda.

2 Comments
  1. Cool man. I was just wondering how to do this. I was putting a turbo button in my racing game. I wanted to only have gas and brake, but no more buttons than that, double tap keeps things simple.

    -nick
    @cellphonegaming

Leave a Reply