Created
March 5, 2013 22:50
-
-
Save Neurogami/5095085 to your computer and use it in GitHub Desktop.
Demo code for Leap game
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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