Change color of StatView and FPS print out

By default these things print out in white in the lower left corner of the screen. is there any way to change this? I just can’t see white text on my game but I really would look to see the FPS read out. If There were a way to change its color (or also I’d like to make it bigger!) that would really help me to see it!

Does anyone know how to do this?

[java]
statsView.setLocalScale(2);
for ( Spatial s : statsView.getChildren() ) {
if (s instanceof BitmapText) {
((BitmapText)s).setColor(ColorRGBA.Red);
}
}
[/java]

Edit: Seems that a lot have changed since I have last looked at SimpleApplication… You will probably need to mess with StatsAppState these days.

1 Like

thanks you put me in the right direction…

just as a heads up to future readers… I kind of figured this out…

[java]StatsView statsView = stateManager.getState(StatsAppState.class).getStatsView();

            statsView.setLocalScale(2);

            for (Spatial s : statsView.getChildren()) {

                    if (s instanceof BitmapText) {

                            ((BitmapText) s).setColor(ColorRGBA.Red);

                    }

            }[/java] 

however… I’ve only been able to call this within the simpleUpdate() method. If I call it in simpleInitApp() statsView is null… meaning that it doesn’t get set up until after simpleInitApp(). Perhaps this is something that someone can look in to on a future version…

the fpsText BitmapText is a protected variable in SimpleApplication, meaning it is easy to just do

[java]this.fpsText.setColor(ColorRGBA.Red);[/java] in the simpleInitApp()… you can also scale it but you can’t translate it. so I wouldn’t recommend scaling it too much

@icamefromspace said: however... I've only been able to call this within the simpleUpdate() method. If I call it in simpleInitApp() statsView is null... meaning that it doesn't get set up until after simpleInitApp(). Perhaps this is something that someone can look in to on a future version...

The stats app state isn’t initialized until after simpleInitApp(). If you moved your game logic to your own app state then it wouldn’t be an issue since your app state would be initialized after simpleInitApp() also.

Anyway, if you are running the latest version of JME (don’t know if it made it into stable) then the stats display has a darker background so that the text is more visible.

1 Like

thanks for the information. I’m still new to jmonkey I haven’t even begun to look at appstates really.