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:


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

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.