voidmen

PIXI.Text with solid color background

Recommended Posts

hey guys,

I'm wondering if there is an easy and efficient way to add background to the PIXI.Text object. For now, my plan is to add a scaled solid color image as background and put them in the right position. Not sure if this is the recommended way.

 

Thanks

Share this post


Link to post
Share on other sites
// text
const textSprite = new PIXI.Text(`blabla`, {fill:"#ff8000"});
const txtBG = new PIXI.Sprite(PIXI.Texture.WHITE);
txtBG.width = textSprite.width,txtBG.height = textSprite.height;
// cage text
const cage = new PIXI.Container();
cage.addChild(txtBG,textSprite);
// add reference for easy debug
cage.name = "textSprite";
cage.textSprite = textSprite;
cage.txtBG = txtBG;

Share this post


Link to post
Share on other sites
17 hours ago, jonforum said:
// text
const textSprite = new PIXI.Text(`blabla`, {fill:"#ff8000"});
const txtBG = new PIXI.Sprite(PIXI.Texture.WHITE);
txtBG.width = textSprite.width,txtBG.height = textSprite.height;
// cage text
const cage = new PIXI.Container();
cage.addChild(txtBG,textSprite);
// add reference for easy debug
cage.name = "textSprite";
cage.textSprite = textSprite;
cage.txtBG = txtBG;

Thanks a lot man!

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.