Skip to content

Instantly share code, notes, and snippets.

@thelucre
Created March 14, 2019 17:03
Show Gist options
  • Save thelucre/50944726197d6130095af1e26553dabd to your computer and use it in GitHub Desktop.
Save thelucre/50944726197d6130095af1e26553dabd to your computer and use it in GitHub Desktop.
Binding to Scene events in Snapchat Lens Studio
// -----JS CODE-----
/**
* UpdateEvent, fires every frame
* @param {UpdateEvent} ev
*/
// Callback for the UpdateEvent
function onUpdate(ev) {
print(getDeltaTime());
}
// Binding our callback to the UpdateEvent
var updateEvent = script.createEvent("UpdateEvent");
updateEvent.bind(onUpdate);
/**
* BrowsRaisedEvent, triggered when the user's brows change to raised.
* Lens Studio does all of this detection for us, we just listen for the event.
* @param {BrowsRaisedEvent} ev
*/
// Callback for the BrowsRaisedEvent
function onBrowsRaised(ev) {
print("My, what high brows you have!");
}
// Binding our callback to the BrowsRaisedEvent
var browsRaisedEvent = script.createEvent("BrowsRaisedEvent");
browsRaisedEvent.bind(onBrowsRaised);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment