dont do it with Text3D, you should only use that for static text, if you create a 3d text every update cycle you wont have any FPS
take a look at DebugGameState if you use StandardGame, or look at any of the tests in the jme 2.0 source, in those you can toggle a statistik view with many values (incl. FPS)
if you still want to do it on your own:
public void init(StandardGame game) {
// Then our font Text object.
// This is what will actually have the text at the bottom.
fps = Text.createDefaultTextLabel("FPS label");
fps.setCullHint(CullHint.Never);
fps.setTextureCombineMode(TextureCombineMode.Replace);
// Finally, a stand alone node (not attached to root on purpose)
fpsNode = new Node("FPS node");
fpsNode.setRenderState(fps.getRenderState(StateType.Blend));
fpsNode.setRenderState(fps.getRenderState(StateType.Texture));
fpsNode.attachChild(fps);
fpsNode.setCullHint(CullHint.Never);
fpsNode.updateGeometricState(0.0f, true);
fpsNode.updateRenderState();
} // init
public void update(float tpf) {
// print the FPS information
StringBuffer updateBuffer = new StringBuffer();
updateBuffer.append("FPS: ").append(Math.round(1 / tpf));
/* Send the fps to our fps bar at the bottom. */
fps.print(updateBuffer);
} // update
public void render(float tpf) {
game.getDisplay().getRenderer().draw(fpsNode);
} // render
sorry for being unclear before: you should not integrate the functionality from StatisticsGameState into your GameState. somewhere in your code you should have something like that:
right below it, you can create your StatisticsGameState and add it to the GameStateManager, just like above. Else, you would just screw up the whole point of GameStates ;)