TouchDataProvider
Lens Studio v1.0.0+
Inherits from ScriptObject
Description
This provider is returned by global.touchSystem
and allows your lens to handle any touches on the screen, and optionally let certain touch types to pass through (let Snapchat handle the touch).
Possible TouchType exception values:
- “TouchTypeNone”
- “TouchTypeTouch”
- “TouchTypeTap”
- “TouchTypeDoubleTap”
- “TouchTypeScale”
- “TouchTypePan”
- “TouchTypeSwipe”
Methods
composeTouchBlockingExceptionMask(Number currentMask, String newException)
: Number
Returns a copy of currentMask
with the newException
flag set to true.
enableTouchBlockingException(String exception, Boolean enable)
: void
Allow or stop allowing a certain TouchType
to pass through your lens. Useful for allowing Snapchat to handle certain TouchType
, e.g. allowing TouchTypeDoubleTap
to flip the camera.
Properties
touchBlocking
: Boolean
Set your lens to handle touches on the screen, preventing default Snapchat touch behavior from occuring. Useful for enabling full screen touches without any touch components. It is similar to creating a plane the size of the screen in front of the camera.
touchBlockingExceptionMask
: Number
The current touch mask.
Inherited Methods
getTypeName()
: String
Returns the name of this object’s type.
isOfType(String type)
: Boolean
Returns true if the object matches or derives from the passed in type.
Examples
// Enable full screen touches
global.touchSystem.touchBlocking = true;
// Allow double-tap to be passed through to Snapchat to flip the camera.
global.touchSystem.enableTouchBlockingException("TouchTypeDoubleTap", true);
// Or alternatively enable "TouchTypeDoubleTap" using mask
var mask = touchComponent.touchBlockingExceptionMask;
mask = touchComponent.composeTouchBlockingExceptionMask(mask, "TouchTypeDoubleTap");
touchComponent.touchBlockingExceptionMask = mask;
Still Looking for help?
Visit Support