I’ve tried to attach the appstate, but I get
java.lang.NullPointerException
at com.simsilica.lemur.Label.<init>(Label.java:101)
at com.simsilica.lemur.Label.<init>(Label.java:78)
at com.simsilica.state.DebugHudState$DebugView.<init>(DebugHudState.java:247)
at com.simsilica.state.DebugHudState.createDebugValue(DebugHudState.java:100)
You left out important parts of the stack trace (so frustrating) so I have to guess… but it seems like you are calling createDebugValue() with a null name.
“Sample of SiO2 DebugHudState?”
…same as the sample for everything else:
1 Like
A side note: this code don’t work because Lemur is not initialized. But SiO2 lets the user discover it by himself 
import com.jme3.app.SimpleApplication;
import com.jme3.app.state.AppState;
import com.simsilica.state.DebugHudState;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
public class HelloJME3 extends SimpleApplication {
public static void main(String[] args) {
HelloJME3 app = new HelloJME3(new DebugHudState());
app.start(); // start the game
}
public HelloJME3(AppState... appstates) {
super(appstates);
}
@Override
public void simpleInitApp() {
}
}
Still didn’t understand what I did wrong:
import com.jme3.app.SimpleApplication;
import com.jme3.app.state.AppState;
import com.simsilica.lemur.GuiGlobals;
import com.simsilica.lemur.core.VersionedHolder;
import com.simsilica.state.DebugHudState;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
public class HelloJME3 extends SimpleApplication {
private VersionedHolder<String> positionDisplay;
public static void main(String[] args) {
HelloJME3 app = new HelloJME3();
app.start(); // start the game
}
public HelloJME3(AppState... appstates) {
super(appstates);
}
@Override
public void simpleInitApp() {
GuiGlobals.initialize(this);
GuiGlobals globals = GuiGlobals.getInstance();
DebugHudState debug=new DebugHudState();
stateManager.attach(debug);
positionDisplay=debug.createDebugValue("aaa", DebugHudState.Location.Bottom);
positionDisplay.setObject("aaa");
}
}
GRAVE: Uncaught exception thrown in Thread[jME3 Main,5,main]
java.lang.NullPointerException
at com.simsilica.state.DebugHudState.createDebugValue(DebugHudState.java:112)
at HelloJME3.simpleInitApp(HelloJME3.java:32)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:220)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:130)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:211)
at java.lang.Thread.run(Thread.java:745)
Well, now you are accessing the state before it has been initialized. You should generally do almost nothing in simpleInitApp() because it runs before anything.
1 Like