espace Posted July 28, 2016 Share Posted July 28, 2016 Hi, My prototype below works but i want to have an option to choose if yes or no i put a tint color. So if tint = "none" my sprite have no tint if i put an another color like 0xFFFFFF then my sprite have this tint color. How do you that ? Thanks e = function (game,nameA,posx,posy,width,height,anchor,tint,alpha) { Phaser.Sprite.call(this,game,posx,posy,nameA) this.x=posx; this.y=posy; this.width=width; this.height=height; this.anchor.set(anchor); this.tint=function(tint) { if ( tint == "none" ) { tint=null; } else { tint=tint; } return tint; } this.alpha=alpha;; game.add.existing(this); } e.prototype = Object.create(Phaser.Sprite.prototype); e.prototype.constructor = e; var example = new e(this.game,'rect',100,100,90,90,.5,"none",1) Link to comment Share on other sites More sharing options...
Fatalist Posted July 28, 2016 Share Posted July 28, 2016 http://phaser.io/docs/2.4.4/Phaser.Sprite.html#tint Link to comment Share on other sites More sharing options...
Skeptron Posted July 28, 2016 Share Posted July 28, 2016 Just so you know, tint is absolutely dreadful to performances. Really, really bad (specially in CANVAS, didn't test it much with WEBGL). Link to comment Share on other sites More sharing options...
espace Posted July 28, 2016 Author Share Posted July 28, 2016 Thanks Fatalist. Skeptron, what is the alternative so ? Link to comment Share on other sites More sharing options...
Fatalist Posted July 28, 2016 Share Posted July 28, 2016 No problem. Tinting is free in WebGL. In canvas it is problematic if your are animating the tint/changing it every frame, that is, there is a performance hit for changing the tint, but not for using the tinted sprite afterwards. Link to comment Share on other sites More sharing options...
espace Posted July 28, 2016 Author Share Posted July 28, 2016 Ok, i'm reassured. Link to comment Share on other sites More sharing options...
Recommended Posts