espace

can't do phaser button prototype

Recommended Posts

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 ?

Share this post


Link to post
Share on other sites

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

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.