Skip to content

Instantly share code, notes, and snippets.

@Neurogami
Created March 5, 2013 22:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Neurogami/5095085 to your computer and use it in GitHub Desktop.
Save Neurogami/5095085 to your computer and use it in GitHub Desktop.
Demo code for Leap game
controller.loop(function(frame) {
if (frame.cursorPosition) {
var position = region.mapToXY(frame.cursorPosition, canvas.width, canvas.height)
if (1 == frame.fingers.length ) {
var position = region.mapToXY(frame.cursorPosition, canvas.width, canvas.height)
Handlers['walkto']( [position[0], position[1]] );
}
if (2 == frame.fingers.length ) {
var v1 = new Vector.create(frame.fingers[0].tipPosition);
var v2 = new Vector.create(frame.fingers[1].tipPosition);
var d = v1.distanceFrom(v2) * 0.15;
Handlers['grow']( d );
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment