Jump to content

BitmapData - replaceRGB


Husky
 Share

Recommended Posts

Hi guys,

 

 

I have some sprites that I'm using to create a composite Image.

 

I'm doing that because if I use all those sprites in my game screen I'll suffer a great loss of FPS.

 

I'm using the BitmapData and drawing layer after layer.

 

The BitmapData doesn't have the tint property, so I'm trying to use the replaceRGB().

 



var bitmap = new Phaser.BitmapData(game);

bitmap.draw('spriteGender_base');
bitmap.replaceRGB(255, 255, 255, 255, 0, 0, 255, 255);
bitmap.draw('spriteGender_shadow');
bitmap.draw('spriteGender_accessories');
bitmap.update();

this.compositeImage = new Phaser.Image(game, x, y, bitmap);



If I try this way my compositeImage only has the "spriteGender_shadow" and "spriteGender_accessories" layers.

If I remove the replaceRGB() I'll get all my layers but no color :/

 

What I'm doing wrong here?

 

Thanks in advance,

Felipe.

Link to comment
Share on other sites

I did this in a slightly different way

var bitmapData = game.make.bitmapData(240, 240);bitmapData.draw(game.cache.getImage('bg'), 0, 0);bitmapData.update();//not sure this is necessary here (it was in a different project, and I left it in.)	bitmapData.processPixelRGB(this.convertBlue, this)		

then

convertBlue: function(col){	//var r = col.r	//var g = col.g;	//var b = col.b;	//var l = (r+g+b)/3;	col.r = 0;	col.g = 0;	col.b = 255;	return col;},

(I've left some of my old code in there, that's in case you wanted to process the colour rather than replace.)

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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