I was wondering if anyone else encountered a similar problem. I have a game which works fine as an jar and exe, however when I run it as applet I get a nullpointerexception:
Exception in thread “LWJGL Renderer Thread” java.lang.NullPointerException
on this line:
Main.app.getStateManager().attach(bulletAppState); (bulletAppState is initialized just before that, so seems to be statemanager)
Any help is very much appreciated,
You use the nightly? There was an error in the StateManager lately, try updating again.
I updated, but I still get the same error in my applet. Also I tried switching some of the functions and got another error but this time on the line
so probably the renderer.
Oh, you use a static accessor for the app but probably initialize it in the main() of your application. Thats not called for an applet. Using static accessors is arguably not good coding practice, you should pass a reference to the app object where you need it, you can access all contained AppStates via app.getStateManager().getState(), so you only need to pass that one object.
Ah damnit… I thought it was so much neater to have it this way… Oh well lesson learned :).
Thanks for the help Normen.
Can you recommend a good coding practice book btw? I read Code Complete and found it quite good.