Phaser.GamepadButton = function (game, buttoncode){ this.game = game; this.isDown = false ; this.isUp = false ; this.timeDown = 0; this.duration = 0; this.timeUp = 0; this.repeats = 0; this.value = 0; this.buttonCode = buttoncode; this.onDown = new Phaser.Signal(); this.onUp = new Phaser.Signal(); this.onFloat = new Phaser.Signal(); } ; Phaser.GamepadButton.prototype = { processButtonDown: function (value){ if (this.isDown) { this.duration = this.game.time.now - this.timeDown; this.repeats++ ; } else { this.isDown = true ; this.isUp = false ; this.timeDown = this.game.time.now; this.duration = 0; this.repeats = 0; this.value = value; this.onDown.dispatch(this, value); } } , processButtonUp: function (value){ this.isDown = false ; this.isUp = true ; this.timeUp = this.game.time.now; this.value = value; this.onUp.dispatch(this, value); } , processButtonFloat: function (value){ this.value = value; this.onFloat.dispatch(this, value); } , justPressed: function (duration){ if (typeof duration === "undefined") { duration = 250; } return (this.isDown && this.duration < duration); } , justReleased: function (duration){ if (typeof duration === "undefined") { duration = 250; } return (this.isDown === false && (this.game.time.now - this.timeUp < duration)); } } ; Phaser.GamepadButton.prototype.constructor = Phaser.GamepadButton;