Last active
August 29, 2015 14:18
-
-
Save netcell/a23da0dc45c04a02d177 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
class Joystick extends Phaser.Sprite { | |
constructor(x, y) { | |
super(game, 0, 0, 'background'); | |
this.anchor.setTo(0.5, 0.5); | |
/* Pin indicator - what players think they drag */ | |
this.pin = game.add.sprite(0, 0, pin); | |
this.pin.anchor.setTo(0.5, 0.5); | |
this.addChild(this.pin); | |
/* Invisible sprite that players actually drag */ | |
var dragger = this.dragger = game.add.sprite(0, 0, null); | |
dragger.anchor.setTo(0.5, 0.5); | |
dragger.width = dragger.height = this.width; | |
dragger.inputEnabled = true; | |
dragger.input.enableDrag(true); | |
this.addChild(dragger); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment