Crafty.multitouch()

Enables/disables support for multitouch feature.

public this .multitouch(Boolean bool)
bool

Turns multitouch on and off. The initial state is off (false).

Query whether multitouch is on or off.

public Boolean .multitouch()
[Returns]

Whether multitouch is currently enabled

By default, touch events are treated as mouse events and are handled by the MouseSystem. To change this behaviour and handle events by the TouchSystem, enable multitouch.

If this is set to true, it is expected that your entities have the Touch component instead of the Mouse component. If false (default), then only entities with the Mouse component will respond to touch. For simple use cases, tt's recommended to add the Button component instead, which requires the proper component depending on this feature.

Note: The multitouch feature is currently incompatible with the Draggable component and Crafty.viewport.mouselook.

Note: When multitouch is not enabled, Crafty will cancel touch events when forwarding them to the mouse system.

Example

Crafty.multitouch(true);
Crafty.log("multitouch is " + Crafty.multitouch());

Crafty.e('2D, Canvas, Color, Button')
   .attr({ x: 100, y: 100, w:200, h:200, z:1 })
   .color('black')
   .bind('TouchStart', function(e) { this.color('green'); });