The hud(dosen't work)
This commit is contained in:
parent
23c221468e
commit
ceee192a28
1 changed files with 54 additions and 0 deletions
54
src/sg/states/HudState.java
Normal file
54
src/sg/states/HudState.java
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
package sg.states;
|
||||
|
||||
import java.awt.Font;
|
||||
|
||||
import com.jme.math.Vector3f;
|
||||
import com.jme.renderer.Renderer;
|
||||
import com.jme.scene.Node;
|
||||
import com.jme.scene.Spatial.LightCombineMode;
|
||||
import com.jme.scene.state.BlendState;
|
||||
import com.jme.system.DisplaySystem;
|
||||
import com.jmex.font3d.Font3D;
|
||||
import com.jmex.font3d.Text3D;
|
||||
import com.jmex.game.state.BasicGameState;
|
||||
|
||||
public class HudState extends BasicGameState{
|
||||
private Node hudNode;
|
||||
|
||||
|
||||
public HudState(String name) {
|
||||
super(name);
|
||||
|
||||
hudNode = new Node("hud");
|
||||
hudNode.setRenderQueueMode(Renderer.QUEUE_ORTHO);
|
||||
hudNode.setLocalTranslation(new Vector3f(
|
||||
DisplaySystem.getDisplaySystem().getWidth()/2,
|
||||
DisplaySystem.getDisplaySystem().getHeight()/2,0));
|
||||
|
||||
//Add the alpha values for the transparent node
|
||||
BlendState as = DisplaySystem.getDisplaySystem().getRenderer().createBlendState();
|
||||
as.setBlendEnabled(true);
|
||||
as.setSourceFunction(BlendState.SourceFunction.SourceAlpha);
|
||||
as.setDestinationFunction(BlendState.DestinationFunction.One);
|
||||
as.setTestEnabled(true);
|
||||
as.setTestFunction(BlendState.TestFunction.GreaterThan);
|
||||
as.setEnabled(true);
|
||||
|
||||
Font3D font = new Font3D(new Font("Arial", Font.PLAIN, 24), 0.001f, true, true, true);
|
||||
Text3D text = font.createText("Testing 1, 2, 3", 50.0f, 0);
|
||||
//text.setLocalScale(new Vector3f(5.0f, 5.0f, 0.01f));
|
||||
hudNode.attachChild(text);
|
||||
|
||||
hudNode = new Node("hud_node");
|
||||
hudNode.setLightCombineMode(LightCombineMode.Off);
|
||||
hudNode.setRenderState(as);
|
||||
hudNode.updateRenderState();
|
||||
rootNode.attachChild(hudNode);
|
||||
}
|
||||
|
||||
public void update(float tpf) {
|
||||
|
||||
// last thing
|
||||
super.update(tpf);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue