Phaser.GamepadButton = function (pad, buttonCode){ this.pad = pad; this.game = pad.game; this.isDown = false ; this.isUp = true ; 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){ this.isDown = true ; this.isUp = false ; this.timeDown = this.game.time.time; 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.time; this.value = value; this.onUp.dispatch(this, value); } , processButtonFloat: function (value){ this.value = value; this.onFloat.dispatch(this, value); } , justPressed: function (duration){ duration = duration || 250; return (this.isDown === true && (this.timeDown + duration) > this.game.time.time); } , justReleased: function (duration){ duration = duration || 250; return (this.isUp === true && (this.timeUp + duration) > this.game.time.time); } , reset: function (){ this.isDown = false ; this.isUp = true ; this.timeDown = this.game.time.time; this.duration = 0; this.repeats = 0; } , destroy: function (){ this.onDown.dispose(); this.onUp.dispose(); this.onFloat.dispose(); this.pad = null ; this.game = null ; } } ; Phaser.GamepadButton.prototype.constructor = Phaser.GamepadButton;