Moai SDK  2.0
MOAITouchSensor Class Reference
+ Inheritance diagram for MOAITouchSensor:

Function List

countTouches
 
down
 
getActiveTouches
 
getCenterLoc
 
getTouch
 
hasTouches
 
isDown
 
setAcceptCancel
 
setCallback
 
setTapMargin
 
setTapTime
 
up
 

Detailed Description

Constants
MOAITouchSensor.TOUCH_DOWN
MOAITouchSensor.TOUCH_MOVE
MOAITouchSensor.TOUCH_UP
MOAITouchSensor.TOUCH_CANCEL

Function Documentation

countTouches

Return the number of currently active touches.


function countTouches ( MOAITouchSensor self )

Parameters
MOAITouchSensorself
Returns
number count
down

Checks to see if the screen was touched during the last iteration.


function down ( MOAITouchSensor self [, number idx ] )

Parameters
MOAITouchSensorself
numberidx Optional. Index of touch to check.
Returns
boolean wasPressed
getActiveTouches

Returns the IDs of all of the touches currently occurring (for use with getTouch).


function getActiveTouches ( MOAITouchSensor self )

Parameters
MOAITouchSensorself
Returns
number idx1, ..., number idxN
getCenterLoc

Get the center coordinate of all currently active touches (as a simple average of all active touch coordinates). Returns nil if no current active touches.


function getCenterLoc ( MOAITouchSensor self )

Parameters
MOAITouchSensorself
Returns
number x, number y
getTouch

Checks to see if there are currently touches being made on the screen.


function getTouch ( MOAITouchSensor self, number id )

Parameters
MOAITouchSensorself
numberid The ID of the touch.
Returns
number x, number y, number tapCount
hasTouches

Checks to see if there are currently touches being made on the screen.


function hasTouches ( MOAITouchSensor self )

Parameters
MOAITouchSensorself
Returns
boolean hasTouches
isDown

Checks to see if the touch status is currently down.


function isDown ( MOAITouchSensor self [, number idx ] )

Parameters
MOAITouchSensorself
numberidx Optional. Index of touch to check.
Returns
boolean isDown
setAcceptCancel

Sets whether or not to accept cancel events ( these happen on iOS backgrounding ), default value is false.


function setAcceptCancel ( MOAITouchSensor self, boolean accept )

Parameters
MOAITouchSensorself
booleanaccept true then touch cancel events will be sent
Returns
nil
setCallback

Sets or clears the callback to be issued when the pointer location changes.


function setCallback ( MOAITouchSensor self [, function callback ] )

Parameters
MOAITouchSensorself
functioncallback Optional. Default value is nil.
Returns
nil
setTapMargin

Sets maximum distance between two touches for them to be considered a tap.


function setTapMargin ( MOAITouchSensor self, number margin )

Parameters
MOAITouchSensorself
numbermargin Max difference on x and y between taps
Returns
nil
setTapTime

Sets the time between each touch for it to be counted as a tap.


function setTapTime ( MOAITouchSensor self, number time )

Parameters
MOAITouchSensorself
numbertime New time between taps
Returns
nil
up

Checks to see if the screen was untouched (is no longer being touched) during the last iteration.


function up ( MOAITouchSensor self [, number idx ] )

Parameters
MOAITouchSensorself
numberidx Optional. Index of touch to check.
Returns
boolean wasPressed