Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

newbie : transform a function in an OOP object


espace
 Share

Recommended Posts

hi,

Could you help me please to transform this snippet in a prototype function to have an oop object ?

with pixi.js i could do it but with phaser i'm a little lost...

thanks for your tips.

 

function draw(e,game,nameA,posx,posy,wi,he,valueAlpha,anchorValue) {  

	var e=game.add.sprite(0,0,nameA);
	e.x=posx;
	e.y=posy;
	e.width=wi;
	e.height=he;
	e.anchor.set(anchorValue)
	e.alpha=valueAlpha

return e
}

//final drawing
function drawE(e,game) {
	var e=[]
		e.player=draw(e,game,"rect",0,0,w,h,1,0)
		e.opponent=draw(e,game,"rect",w2,0,w,h,1,0)
	return e
}

var background= drawE(this.background, game)

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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