Le Twitch

how to update bitmapFont

Recommended Posts

I have a bitmapText that changes colour by changing the bitmapFont. The bitmapFont changes but it doesn't update, so it stays the same colour as before. How do I update the bitmapFont or get around this problem?

Share this post


Link to post
Share on other sites

You can force an update with the following:

bitmapText.updateText();

Though it's often a lot easier to use white text and set a tint the entire bitmapText instance to change the colour.

 

I've already been doing that. I found out what the problem was. Is there a setFont for bitmapText or anything similar? That would pretty much fix my issue

Share this post


Link to post
Share on other sites

Ok, so I dug a bit deeper in the Pixi code and found a quick workaround where you don't set the font but the fontName attribute:

myBitmapText.fontName = "myNewFontKey"; // where "myNewFontKey" refers to a font previously loaded into the cache

You won't find fontName in either documentation since it's only being used as a private field. Essentially, Phaser would also need to set the fontName attribute in the font attributes setter and the problem should be fixed.

 

Update: Filed this issue on GitHub: https://github.com/photonstorm/phaser/issues/1602

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...

  • Recently Browsing   0 members

    No registered users viewing this page.