diff --git a/src/sg/states/InGameState.java b/src/sg/states/InGameState.java index 195ee4c..268647d 100644 --- a/src/sg/states/InGameState.java +++ b/src/sg/states/InGameState.java @@ -16,14 +16,13 @@ import com.jme.scene.state.LightState; import com.jme.system.DisplaySystem; import com.jmex.game.state.CameraGameState; import com.jmex.game.state.GameStateManager; -import com.jmex.game.state.load.LoadingGameState; import com.jmex.physics.DynamicPhysicsNode; import com.jmex.physics.PhysicsDebugger; import com.jmex.physics.PhysicsSpace; import com.jmex.physics.StaticPhysicsNode; public class InGameState extends CameraGameState { - /** The Keyboard/ mous input handler */ + /** The Keyboard/ mouse input handler */ protected InputHandler input; /** The environment of the game */ protected Environment environment; @@ -36,10 +35,6 @@ public class InGameState extends CameraGameState { public InGameState(String name) { super(name); - - LoadingGameState loader = new LoadingGameState(2); - GameStateManager.getInstance().attachChild(loader); - loader.setActive(true); // ***************** Load the Game ********************************** // Pass (render thingies) @@ -57,39 +52,47 @@ public class InGameState extends CameraGameState { // environment environment = new Environment(rootNode); rootNode.attachChild(environment); - loader.increment(); // ship Node ship = SGUtil.loadModel("sg/data/models/ships/G6.3ds"); ship.setLocalTranslation(new Vector3f( 0, 0, 40)); rootNode.attachChild(ship); - loader.increment(); - + // inputs FirstPersonHandler first = new FirstPersonHandler( cam, 50, 1 ); input = new InputHandler(); input.addToAttachedHandlers( first ); - loader.increment(); - + // lights - /** Set up a basic, default light. */ - PointLight light = new PointLight(); - light.setDiffuse( new ColorRGBA( 0.75f, 0.75f, 0.75f, 0.75f ) ); - light.setAmbient( new ColorRGBA( 0.5f, 0.5f, 0.5f, 1.0f ) ); - light.setLocation( new Vector3f( 100, 100, 100 ) ); - light.setEnabled( true ); + /** Set up a basic, default light. */ + PointLight light = new PointLight(); + light.setDiffuse( new ColorRGBA( 0.75f, 0.75f, 0.75f, 0.75f ) ); + light.setAmbient( new ColorRGBA( 0.5f, 0.5f, 0.5f, 1.0f ) ); + light.setLocation( new Vector3f( 100, 100, 100 ) ); + light.setEnabled( true ); - /** Attach the light to a lightState and the lightState to rootNode. */ - LightState lightState = DisplaySystem.getDisplaySystem().getRenderer().createLightState(); - lightState.setEnabled( true ); - lightState.attach( light ); - rootNode.setRenderState( lightState ); - rootNode.updateRenderState(); + /** Attach the light to a lightState and the lightState to rootNode. */ + LightState lightState = DisplaySystem.getDisplaySystem().getRenderer().createLightState(); + lightState.setEnabled( true ); + lightState.attach( light ); + rootNode.setRenderState( lightState ); + rootNode.updateRenderState(); + HudState hud = new HudState("hud"); + GameStateManager.getInstance().attachChild(hud); + + cam.setFrustumFar(5000); // ***************** Done loading ********************************** - loader.setActive(false); - GameStateManager.getInstance().detachChild(loader); - this.setActive(true); + } + + public void onActivate(){ + super.onActivate(); + GameStateManager.getInstance().activateChildNamed("hud"); + } + + public void onDeactivate(){ + super.onDeactivate(); + GameStateManager.getInstance().deactivateChildNamed("hud"); } public void stateUpdate(float tpf) {