TouchStartEvent
Lens Studio v1.0.0+
Scripting Name: TouchStartEvent
Inherits from SceneObjectEvent
Description
Triggered when a touch event starts.
Methods
getTouchId()
: Number
Returns the ID of this specific touch. Useful for distinguishing between touches when multiple are occurring simultaneously.
getTouchPosition()
: vec2
Returns the normalized 2D screen position of the user’s touch. The normalized coordinates range from ([0-1], [0-1]), (0,0) being top-left and (1,1) being bottom-right.
Inherited Methods
getSceneObject()
: SceneObject
Returns the SceneObject this Event is associated with.
bind(function evCallback)
: void
Binds a callback function to this event.
getTypeName()
: String
Returns the typename of the SceneEvent.
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.
Inherited Properties
enabled
: Boolean
If true, the event is able to trigger. If false, the event will not trigger.
Examples
// Prints the touch position when a screen touch has started
var event = script.createEvent("TouchStartEvent");
event.bind(function(eventData)
{
var touchedPos = eventData.getTouchPosition();
print("touch started at " + touchedPos.x + " " + touchedPos.y);
});
Still Looking for help?
Visit Support