Sign in to follow this  
TemperTony

Replacing sprite with one solid color?

Recommended Posts

Hi there, I've been googling this for a while but all I've come up with is how to tint the sprite which isn't the result I want (I've tested, it colorizes the sprite)

So I was wondering if it was possible to just fill the entire sprite with one solid color with no alpha channel?

Thank you!

Share this post


Link to post
Share on other sites

Here you go:

 

var sprite = new PIXI.Sprite(PIXI.Texture.WHITE);
sprite.tint = 0xff0000; //Change with the color wanted
sprite.width = 100;
sprite.height = 100;

maincontainer.addChild(sprite);

Or if it's something that currently exists you could change the sprites .texture to PIXI.Texture.WHITE and tint it.

[Edit]. If you need to have sprite change between normal display and completely tinted then just keep the normal texture stored somewhere and set it back to texture after tinting part is done.

Share this post


Link to post
Share on other sites
2 hours ago, Exca said:

Here you go:

 


var sprite = new PIXI.Sprite(PIXI.Texture.WHITE);
sprite.tint = 0xff0000; //Change with the color wanted
sprite.width = 100;
sprite.height = 100;

maincontainer.addChild(sprite);

Or if it's something that currently exists you could change the sprites .texture to PIXI.Texture.WHITE and tint it.

[Edit]. If you need to have sprite change between normal display and completely tinted then just keep the normal texture stored somewhere and set it back to texture after tinting part is done.

Would setting something that already exists to PIXI.Texture.WHITE be done like this?

sprite.texture = PIXI.Texture.WHITE

 

Share this post


Link to post
Share on other sites

I know this is a rather old post, but when I try the solution, I get white squares where I expected the original texture shape painted solid white. 

// texture is the actual shaped and colored texture:
this.sprite = new PIXI.Sprite(texture);
this.sprite.texture = PIXI.Texture.WHITE;

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.