Jump to content

Deactivate Button


enriqueto
 Share

Recommended Posts

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();
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...