Added hud
This commit is contained in:
parent
b26ee23c41
commit
fa72657e8f
1 changed files with 29 additions and 26 deletions
|
|
@ -16,14 +16,13 @@ import com.jme.scene.state.LightState;
|
||||||
import com.jme.system.DisplaySystem;
|
import com.jme.system.DisplaySystem;
|
||||||
import com.jmex.game.state.CameraGameState;
|
import com.jmex.game.state.CameraGameState;
|
||||||
import com.jmex.game.state.GameStateManager;
|
import com.jmex.game.state.GameStateManager;
|
||||||
import com.jmex.game.state.load.LoadingGameState;
|
|
||||||
import com.jmex.physics.DynamicPhysicsNode;
|
import com.jmex.physics.DynamicPhysicsNode;
|
||||||
import com.jmex.physics.PhysicsDebugger;
|
import com.jmex.physics.PhysicsDebugger;
|
||||||
import com.jmex.physics.PhysicsSpace;
|
import com.jmex.physics.PhysicsSpace;
|
||||||
import com.jmex.physics.StaticPhysicsNode;
|
import com.jmex.physics.StaticPhysicsNode;
|
||||||
|
|
||||||
public class InGameState extends CameraGameState {
|
public class InGameState extends CameraGameState {
|
||||||
/** The Keyboard/ mous input handler */
|
/** The Keyboard/ mouse input handler */
|
||||||
protected InputHandler input;
|
protected InputHandler input;
|
||||||
/** The environment of the game */
|
/** The environment of the game */
|
||||||
protected Environment environment;
|
protected Environment environment;
|
||||||
|
|
@ -36,10 +35,6 @@ public class InGameState extends CameraGameState {
|
||||||
|
|
||||||
public InGameState(String name) {
|
public InGameState(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
|
|
||||||
LoadingGameState loader = new LoadingGameState(2);
|
|
||||||
GameStateManager.getInstance().attachChild(loader);
|
|
||||||
loader.setActive(true);
|
|
||||||
// ***************** Load the Game **********************************
|
// ***************** Load the Game **********************************
|
||||||
|
|
||||||
// Pass (render thingies)
|
// Pass (render thingies)
|
||||||
|
|
@ -57,19 +52,16 @@ public class InGameState extends CameraGameState {
|
||||||
// environment
|
// environment
|
||||||
environment = new Environment(rootNode);
|
environment = new Environment(rootNode);
|
||||||
rootNode.attachChild(environment);
|
rootNode.attachChild(environment);
|
||||||
loader.increment();
|
|
||||||
|
|
||||||
// ship
|
// ship
|
||||||
Node ship = SGUtil.loadModel("sg/data/models/ships/G6.3ds");
|
Node ship = SGUtil.loadModel("sg/data/models/ships/G6.3ds");
|
||||||
ship.setLocalTranslation(new Vector3f( 0, 0, 40));
|
ship.setLocalTranslation(new Vector3f( 0, 0, 40));
|
||||||
rootNode.attachChild(ship);
|
rootNode.attachChild(ship);
|
||||||
loader.increment();
|
|
||||||
|
|
||||||
// inputs
|
// inputs
|
||||||
FirstPersonHandler first = new FirstPersonHandler( cam, 50, 1 );
|
FirstPersonHandler first = new FirstPersonHandler( cam, 50, 1 );
|
||||||
input = new InputHandler();
|
input = new InputHandler();
|
||||||
input.addToAttachedHandlers( first );
|
input.addToAttachedHandlers( first );
|
||||||
loader.increment();
|
|
||||||
|
|
||||||
// lights
|
// lights
|
||||||
/** Set up a basic, default light. */
|
/** Set up a basic, default light. */
|
||||||
|
|
@ -86,10 +78,21 @@ public class InGameState extends CameraGameState {
|
||||||
rootNode.setRenderState( lightState );
|
rootNode.setRenderState( lightState );
|
||||||
rootNode.updateRenderState();
|
rootNode.updateRenderState();
|
||||||
|
|
||||||
|
HudState hud = new HudState("hud");
|
||||||
|
GameStateManager.getInstance().attachChild(hud);
|
||||||
|
|
||||||
|
cam.setFrustumFar(5000);
|
||||||
// ***************** Done loading **********************************
|
// ***************** 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) {
|
public void stateUpdate(float tpf) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue