espace Posted June 30, 2018 Share Posted June 30, 2018 hi, i success to make a simple button like the example in the doc, but when i try to make a button prototype it don't works. i receive no error and i can't see my button. But in the console i see my object button, visible on true etc.... _bu = function (p) {//parameter Phaser.Button.call(this, p.g, p.x, p.y, p.image,p.callback,this,0,0,0); p.a != null ? this.alpha = p.a : this.alpha = 1 p.v != null ? this.visible = p.v : this.visible = true p.anchorx != null ? this.anchor.x = p.anchorx : this.anchor.x = .5 p.anchory != null ? this.anchor.y = p.anchory : this.anchor.y = .5 p.flag != null ? this.flag = p.flag : this.flag = "undefined" }; _bu.prototype = Object.create(Phaser.Button.prototype); _bu.prototype.constructor = _bu var coucou =()=>{console.log("coucou")} var interface={}; interface.restart_p = { g: game, image: "restart", x: 1400, y: 400, v: true, callback : coucou, } interface.restart = new _bu(interface.restart_p) an idea ? Link to comment Share on other sites More sharing options...
espace Posted June 30, 2018 Author Share Posted June 30, 2018 find by myself: _bu = function (p) { Phaser.Button.call(this,p.g,p.x,p.y,p.image,p.callback,this,0,0,0); p.a != null ? this.alpha = p.a : this.alpha = 1 p.v != null ? this.visible = p.v : this.visible = true p.anchorx != null ? this.anchor.x = p.anchorx : this.anchor.x = .5 p.anchory != null ? this.anchor.y = p.anchory : this.anchor.y = .5 p.flag != null ? this.flag = p.flag : this.flag = "undefined" game.add.existing(this) }; _bu.prototype = Object.create(Phaser.Button.prototype); _bu.prototype.constructor = _bu Link to comment Share on other sites More sharing options...
Recommended Posts