Touch and hold for an allotted amount of time?
by CharlesL · in iTorque 2D · 02/04/2013 (3:42 pm) · 4 replies
I have a quick question - is there a simple way to have a function that will be called only after the sprite has been touched and held for a few seconds? Will I have to use a timer?
Example code would be much appreciated.
Thanks,
- Charles
Example code would be much appreciated.
Thanks,
- Charles
Torque Owner Joe Williams
Newborn Games
function sprite::onTouchDown( %this, %touchID, %worldPos ) { //set timer for 3 seconds %timerTick = 3000; %this.setTimerOn( %timerTick ); } function sprite::onTouchUp( %this, %touchID, %worldPos ) { %this.setTimerOff(); //stop the timer if the player releases touch } function sprite::onMouseLeave( %this, %modifier, %worldPosition, %clicks ) { %this.setTimerOff(); //stop timer if the player's touch leaves the sprite } function sprite::onTimer( %this ) { %this.setTimerOff(); //stop the timer %this.takeAction(); //execute timer action }