tap

Type Event
Dispatch chain Display ObjectRuntime
Revision 2017.3077
Keywords tap
See also Tap/Touch/Multitouch (guide)
system.setTapDelay()

Overview

Generates a hit event when the user touches the screen. The event is dispatched to display objects in the display hierarchy. This is similar to the touch event except a hit count (number of taps) is available in the event callback.

Properties

Examples

Function Listener
local object = display.newImage( "ball.png" )
object.name = "ball object"

local function onObjectTap( event )
    print( "Tap event on: " .. event.target.name )
    return true
end
object:addEventListener( "tap", onObjectTap )
Table Listener 1
local object = display.newImage( "ball.png" )
object.name = "ball object"

local function onObjectTap( self, event )
    print( "Tap event on: " .. self.name )
    return true
end 

object.tap = onObjectTap
object:addEventListener( "tap", object )
Table Listener 2
local object = display.newImage( "ball.png" )
object.name = "ball object"

function object:tap( event )
    print( "Tap event on: " .. self.name )
    return true
end 
object:addEventListener( "tap", object )