CAAT.Foundation.Actor

Actors touch events

CAAT offers out-of-the-box multitouch support.

The framework, is smart enough to route to any given actor, only touch information relating to it. So multitouch events on a canvas/DOM element, can lead to touch events being routed to different actors.

Multitouch, is disabled by default in favor of a touch-as-mouse multitouch behavior. CAAT can't switch from touch-as-mouse to multitouch at will, so this feature must be selected previously to creating a CAAT.Director object instance.

Gestures, where available, and if the actor has setGestureEnabled(bool) will also be delivered to the actor identified by the first registered touch event.

The CAAT.TOUCH_BEHAVIOR internal variable can be assigned to:

  • CAAT.TOUCH_AS_MOUSE, which is the default value
  • CAAT.TOUCH_AS_MULTITOUCH, which enables multitouch support.
  • Touch events, will be notified to the following Actor functions:

  • touchStart( CAAT.TouchEvent )
  • touchMove( CAAT.TouchEvent )
  • touchEnd( CAAT.TouchEvent )
  • Gestures, when explicitly enabled on an Actor, will be notified to the following Actor functions:

  • gestureStart( rotation, scaleX, scaleY )
  • gestureEnd( rotation, scaleX, scaleY )
  • gestureChange( rotation, scaleX, scaleY ). This method, by default, handles rotation and scale of the Actor, and must be overriden if this behavior is not desired.
  • Each device, will support a different number of touch events at the same time. Regardless of this number, CAAT will find each touch affected Actor, and call those Touch handling methods with an instance of CAAT.TouchEvent. This class, resembles a regular browser touch event object, and contains touch information in its members:

  • touches list of current active touches.
  • changedTouches list of affected touches.
  • Refer to this demo with a touch enabled device to test its multitouch capabilities.