Game Development Reference
In-Depth Information
private function onTouchEnd( _evt:TouchEvent ):void
{
mTouching = false;
}
When a new touch is detected, onTouchBegin is called. It trans-
lates the position of the touch into the coordinate space defined in
the init function and then compares it to the internally stored posi-
tion. If it falls within the threshold, the touching flag is set to true
and onTouchMove is called manually to force an update of the
position. onTouchMove is called automatically whenever movement
occurs on the touch display. When the touch is no longer detected,
onTouchEnd is called, setting the flag back to false.
// For Desktop debugging
private function onMouseDown( _evt:MouseEvent ):void
{
var newPosition:Point = new Point( _evt.stageX, _evt.stageY
)
newPosition = mCoordinateSpace.globalToLocal(newPosition);
if (Point.distance( mPosition, newPosition ) < = mDistance
Threshold )
{
mTouching = true;
onMouseMove( _evt );
}
}
private function onMouseMove( _evt:MouseEvent ):void
{
if (mTouching)
{
mPosition.x = _evt.stageX;
mPosition.y = _evt.stageY;
mPosition = mCoordinateSpace.globalToLocal
(mPosition);
}
}
private function onMouseUp( _evt:MouseEvent ):void
{
mTouching = false;
}
These three methods are the mouse versions of the touch hand-
lers we just examined. You
re practically identical
because the events are so similar. This was a very wise move on
'
ll notice that they
'
Search Nedrilad ::




Custom Search