enriqueto Posted February 12, 2014 Share Posted February 12, 2014 It is possible to activate/deactivate a Phaser.Button? Link to comment Share on other sites More sharing options...
rich Posted February 13, 2014 Share Posted February 13, 2014 Not in the traditional UI sense of de-activated, no, sorry (as in sort of greys itself out). Could be done in custom code quite easily though. Link to comment Share on other sites More sharing options...
hpcodecraft Posted February 13, 2014 Share Posted February 13, 2014 You can try this:var MyButton = function(game, x, y, key, callback, callbackContext, overFrame, outFrame, downFrame, upFrame, group) { Phaser.Button.call(this, game, x, y, key, callback, callbackContext, overFrame, outFrame, downFrame, upFrame, group); game.add.existing(this);};MyButton.prototype = Object.create(Phaser.Button.prototype);MyButton.prototype.constructor = MyButton;MyButton.prototype.activate = function() { this.input.enabled = true; this.frame = 0;};MyButton.prototype.deactivate = function() { this.input.enabled = false; this.frame = 2; // change this to match your greyed out frame in the button spritesheet};Usage:var button = new MyButton(game, 0, 0, 'button-sprite', buttonCallback, this);button.deactivate();button.activate(); BdR 1 Link to comment Share on other sites More sharing options...
Recommended Posts