and it seems to work fine as long as I comment out the camera.setUp(...) line. If I put that line in it shows a black screen. This has happened to me more than once, is there something I'm not doing that I should be, or am that I should not?
Sorry for the 50 questions today, I'm trying to finish up Roll-A-Rama and it's primarily bug-fixing time. :)
Looks ok for me. And it's nearly the same what BaseSimpleGame.initSystem does, except that setFrame is used there. Try using that method and report back here if it helps (it shouldn't).
I've already tried that, didn't make any difference. It's a problem I'm having when switching between game states.
Roll-A-Rama does as a fade-in to the main menu, you navigate through, join a soccer server, fade-out, fade-in to the soccer game. All works great there. I then hit escape, prompts me asking if I want to return to the menu, I click okay, fade-out, then fade-in back to the main menu except now I'm rotated (if I don't setUp(…)) and I've got a black screen if I do setUp(…).
I have a ChaseCamera that I use in-game, could that be part of it? It is part of a custom input handler though isn't being updated after the game state has been disabled though. This is not a really big issue at the moment, except I've been trying to get smooth transitions to work and I'm so close.
BTW, I developed a GameManager that I'd be happy to release the source for after this game is finished that is entirely based around GameStates and further has features for ManagedGameStates (which is my custom extension that adds some extras) and I've got it so fade transitions between games are one line of code:
This simply does a fade-out on "start", disables that game state, displays "image" (if it is not null), inits "end", enables end, then fades back in. The timeInSeconds is the amount of time the fade-in/fade-out takes. Would anyone else be interested in this or should it remain proprietary? ;)
By the way, I also have a problem involving camera and states. Here it goes:
I've written a few states for the game's menus. All menus implement a base class
which extends the StandardGameState and overrides the initCamera() method like so:
protected void initCamera() {
super.initCamera();
Vector3f loc = new Vector3f(0.0f, 0.0f, 5.0f);
Vector3f left = new Vector3f(-1.0f, 0.0f, 0.0f);
Vector3f up = new Vector3f(0.0f, 1.0f, 0.0f);
Vector3f dir = new Vector3f(0.0f, 0f, -1.0f);
// Move our camera to a correct place and orientation.
getCamera().setFrame(loc, left, up, dir);
getCamera().update();
}
Now when I start the game, the main menu displays just fine, but when
I try to switch to the settings menu then the following exceptions are thrown:
java.lang.reflect.InvocationTargetException
at java.awt.EventQueue.invokeAndWait(EventQueue.java:851)
at javax.swing.SwingUtilities.invokeAndWait(SwingUtilities.java:1257)
at com.jmex.awt.swingui.JMEDesktop.onButton(JMEDesktop.java:403)
at com.jmex.awt.swingui.JMEDesktop$ButtonAction.performAction(JMEDesktop.java:1060)
at com.jme.input.ActionTrigger.performAction(ActionTrigger.java:253)
at com.jme.input.InputHandler.update(InputHandler.java:462)
at com.jme.input.InputHandler.update(InputHandler.java:470)
at fps.states.BaseMenuState.stateUpdate(BaseMenuState.java:236)
at com.jme.app.StandardGameStateDefaultCamera.update(StandardGameStateDefaultCamera.java:90)
at com.jme.app.GameStateNode.update(GameStateNode.java:71)
at fps.DebugState.update(DebugState.java:236)
at com.jme.app.GameStateNode.update(GameStateNode.java:71)
at fps.FPSGame.update(FPSGame.java:207)
at com.jme.app.VariableTimestepGame.start(VariableTimestepGame.java:102)
at fps.FPSGame.main(FPSGame.java:84)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:86)
Caused by: java.lang.NullPointerException
at org.lwjgl.opengl.GL11.glMatrixMode(GL11.java:1718)
at com.jme.renderer.lwjgl.LWJGLCamera.onFrustumChange(LWJGLCamera.java:116)
at com.jme.renderer.AbstractCamera.<init>(AbstractCamera.java:213)
at com.jme.renderer.lwjgl.LWJGLCamera.<init>(LWJGLCamera.java:70)
at com.jme.renderer.lwjgl.LWJGLRenderer.createCamera(LWJGLRenderer.java:223)
at com.jme.app.StandardGameState.initCamera(StandardGameState.java:109)
at fps.states.BaseMenuState.initCamera(BaseMenuState.java:114)
at com.jme.app.StandardGameState.<init>(StandardGameState.java:76)
at fps.states.BaseMenuState.<init>(BaseMenuState.java:66)
at fps.states.SettingsMenuState.<init>(SettingsMenuState.java:92)
at fps.states.MainMenuState$2.actionPerformed(MainMenuState.java:124)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:234)
at org.jvnet.substance.utils.RolloverButtonListener.mouseReleased(RolloverButtonListener.java:79)
at java.awt.Component.processMouseEvent(Component.java:5488)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3126)
at java.awt.Component.processEvent(Component.java:5253)
at java.awt.Container.processEvent(Container.java:1966)
at java.awt.Component.dispatchEventImpl(Component.java:3955)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Component.dispatchEvent(Component.java:3803)
at com.jmex.awt.swingui.JMEDesktop.dispatchEvent(JMEDesktop.java:603)
at com.jmex.awt.swingui.JMEDesktop.sendAWTMouseEvent(JMEDesktop.java:782)
at com.jmex.awt.swingui.JMEDesktop.access$800(JMEDesktop.java:94)
at com.jmex.awt.swingui.JMEDesktop$6.run(JMEDesktop.java:405)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Does creating more than one camera cause the problem? Any suggestions?