Created
April 3, 2015 05:05
-
-
Save netcell/0b45044dbd86e1b7d776 to your computer and use it in GitHub Desktop.
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
constructor(x, y) { | |
... | |
this.isBeingDragged = false; | |
dragger.events.onDragStart.add(this.onDragStart, this); | |
dragger.events.onDragStop.add(this.onDragStop, this); | |
... | |
} | |
onDragStart(){ | |
this.isBeingDragged = true; | |
} | |
onDragStop(){ | |
this.isBeingDragged = false; | |
/* Reset pin and dragger position */ | |
this.dragger.position.setTo(0, 0); | |
this.pin.position.setTo(0, 0); | |
} | |
update(){ | |
if (this.isBeingDragged) { | |
var distance = this.dragger.getMagnitude(); | |
this.pin.position.copyFrom(this.dragger); | |
if (distance > 90) this.pin.setMagnitude(90); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment