AppState Initialize not being called

After I create a simple appstate that manages camera control and attach it to the state manager in my games simpleinitapp method the appstates initialize method is never being called. If I simply call initialize from the simpleinitapp everything works fine. I’m subclassing SimpleApplication for my main game code and AbstractAppState for my camera control appstate. I’m writing this in scala but I don’t think that’s the issue because as I said everything works fine when I explicitly call the initialize method.

I think the issue is in your setup, yes. If update() is called on the AppState at some point but initialize() never then theres something really strange going on in your application.

Any ideas for troubleshooting at this point? Is there a reason not to directly call initialize? To give some more background on my setup I’m using SBT to compile and run my program. It’s using scala 2.9.1 with all the jars from the download simply dumped into the unmanaged lib folder which I believe just adds the jars to the programs classpath. I would really appreciate any further help on this as I really like JME and it would be super cool if it would play nicely with scala

Don’t call initialize yourself, this can cause many problems. Are you sure your using the same method signature? put @override above to be sure. If that fails, show the code

As wezrule says, you should never ever call initialize() directly; that’s simply not what the routine is for. Read the Javadocs! (That was a shameless plug: I reworked them; give feedback if they were misleading or incomprehensible to you.)

Instead of calling initialize() or update() or cleanup(), you should attach() the AppState to an AppStateManager, which will take care of doing these calls inside the main rendering loop.

@michael.e.shelton said: After I create a simple appstate that manages camera control and attach it to the state manager in my games simpleinitapp method the appstates initialize method is never being called. If I simply call initialize from the simpleinitapp everything works fine. I'm subclassing SimpleApplication for my main game code and AbstractAppState for my camera control appstate. I'm writing this in scala but I don't think that's the issue because as I said everything works fine when I explicitly call the initialize method.

initialize() is always called if the app state is attached. As others have said, you must have overridden it incorrectly. If initialize is “not called” there are only three possible explanations:

  1. the app state was not really attached (though if update is called automatically then it was obviously attached)
  2. your way of determining if it is called or not is incorrect (How do you know it isn’t being called?)
  3. you have added an initialize() to your class that does not match the real initialize() signature and so is not really overriding the AppState’s initialize. Two ways to tell: use @Override on the method then the compiler will complain if it’s different, or don’t extend AbstractAppState and then you will be forced to implement every AppState method yourself and know they are right. @Override is much easier.

My bad, I was passing in SimpleApplication instead of simply Application, I feel dumb… Thanks for the help!

@michael.e.shelton: Nope, you are supposed to use SimpleApplication, not Application, for any type of game/application. You seem to hack the engine severely, you should probably go through the tutorials and documentation even though you will be using Scala… First get to know the engine, then wrap it up in another language.

@normen said: @michael.e.shelton: Nope, you are supposed to use SimpleApplication, not Application, for any type of game/application. You seem to hack the engine severely, you should probably go through the tutorials and documentation even though you will be using Scala.. First get to know the engine, then wrap it up in another language.

I think he meant that his initialize() method had the wrong signature… but I will let him clarify.