[SOLVED]appState access to Application.settings

I am trying to convert my code to using appState

I am trying to make a class “MenuAppState extends AbstractAppState”

Can anyone help me figure out how to add a texture to the guiNode.
I want to get access to the protected SimpleApplication.settings

I want getHeight() and getWidth() so that I can use the values for centering

What is the best way to do this in a appState
public class MenuAppState extends AbstractAppState

public void addHUDTexture() {
Picture pic = new Picture(“HUD Picture”);
pic.setImage(this.app.getAssetManager(), “Textures/ColoredTex/Monkey.png”, true);
pic.setWidth(settings.getWidth() / 2); //<-----------------How to get access to settings
pic.setHeight(settings.getHeight() / 2);
pic.setPosition(settings.getWidth() / 4, settings.getHeight() / 4);

app.getCamera().getWidth() ?

Your app was passed in to the app state when it was initialized, or you can always set up a singleton for the application…

There should probably be a getter for the settings protected field, but you can make you own public accessor for it in your SimpleApplication derived class, then access it though that

edit: that should work as well as long as your camera is the same size as the screen

1 Like

Also, Application is passed to the initialize() method of the app state. You grab that and/or cast it to your own SimpleApplication subclass or whatever… then expose whatever you want.

The other responses seemed to assume this was already known but I wasn’t sure.

I ended up adding a public method to my Class that Extends the SimpleApplication to expose the settings value

Then Casting the app variable in my AppState to the Class that has the public method

Thanks for the help

Happy New Year!

Also, if you just want the app settings object: app.getContext().getSettings() will give you the ones that are currently in effect.

1 Like