Skip to content

Instantly share code, notes, and snippets.

@netcell
Created April 3, 2015 05:05
Show Gist options
  • Save netcell/0b45044dbd86e1b7d776 to your computer and use it in GitHub Desktop.
Save netcell/0b45044dbd86e1b7d776 to your computer and use it in GitHub Desktop.
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