SetOnGenSpriteTouchSub


SetOnGenSpriteTouchSub sprite, onSpriteTouch()

Sets the on sprite touched subroutine for the specified sprite. Once set, the specified onSpriteTouch() subroutine will be automatically called when the sprite is touched.



include "Game Engine Constants.inc"

'...Turn on the game engine and init a sprite...

SetOnGenSpriteTouchSub sprite, onSpriteTouch()

'...continue with program...

Sub onSpriteTouch(sprite, action, index, x, y)

End Sub


sprite

The Game Engine sprite object. This is the sprite that triggered the event sub.

action

' Touch Action Codes
Const Touch_No_action = -1
Const Touch_Down = 0
Const Touch_Up = 1
Const Touch_Move = 2
Const Touch_Cancel = 3
Const Touch_outside_UI = 4
Const Touch_Pointer_Down = 5
Const Touch_Pointer_Up = 6

index

The index indicates which point is being touched. This is used for multi-touch support.

x, y

The coordinates of the touch are stored in x and y.

Programs should always be prepared to handle Touch Cancel events and should tolerate anomalous situations such as receiving a new Touch Down without first having received a Touch Up for the prior gesture.


SetOnGenSpriteTouchSub sprite, Off

Turns off the automatic subroutine call.


Game Engine Events


Event Triggered Subs






Become a Patron