SimpleApplication has now built in methods to display or not fps tex and stat view.

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7008 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
rem..om 2011-03-17 17:27:07 +00:00
parent 6e76c602e4
commit d9f39f6b0b

View File

@ -73,6 +73,7 @@ public abstract class SimpleApplication extends Application {
protected StatsView statsView; protected StatsView statsView;
protected FlyByCamera flyCam; protected FlyByCamera flyCam;
protected boolean showSettings = true; protected boolean showSettings = true;
private boolean showFps = true;
private AppActionListener actionListener = new AppActionListener(); private AppActionListener actionListener = new AppActionListener();
private class AppActionListener implements ActionListener { private class AppActionListener implements ActionListener {
@ -227,11 +228,13 @@ public abstract class SimpleApplication extends Application {
float tpf = timer.getTimePerFrame() * speed; float tpf = timer.getTimePerFrame() * speed;
secondCounter += timer.getTimePerFrame(); if (showFps) {
int fps = (int) timer.getFrameRate(); secondCounter += timer.getTimePerFrame();
if (secondCounter >= 1.0f) { int fps = (int) timer.getFrameRate();
fpsText.setText("Frames per second: " + fps); if (secondCounter >= 1.0f) {
secondCounter = 0.0f; fpsText.setText("Frames per second: " + fps);
secondCounter = 0.0f;
}
} }
// update states // update states
@ -251,6 +254,17 @@ public abstract class SimpleApplication extends Application {
stateManager.postRender(); stateManager.postRender();
} }
public void setDisplayFps(boolean show) {
showFps = show;
fpsText.setCullHint(show ? CullHint.Never : CullHint.Always);
}
public void setDisplayStatView(boolean show) {
statsView.setEnabled(show);
statsView.setCullHint(show ? CullHint.Never : CullHint.Always);
}
public abstract void simpleInitApp(); public abstract void simpleInitApp();
public void simpleUpdate(float tpf) { public void simpleUpdate(float tpf) {