projet-programmation-orient.../core/src/sagittarius/model/FPS.java

40 lines
893 B
Java
Raw Normal View History

2021-04-09 12:53:55 +00:00
package sagittarius.model;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.scenes.scene2d.Actor;
2021-04-13 19:08:25 +00:00
import com.badlogic.gdx.scenes.scene2d.Stage;
2021-04-09 12:53:55 +00:00
import sagittarius.view.GameScreen;
public class FPS extends Actor {
2021-04-09 12:53:55 +00:00
// ---------- ATTRIBUTEs ----------
private int frameRate;
// ---------- METHODs ----------
2021-04-13 19:08:25 +00:00
public FPS(Stage stage) {
super();
setPosition(3, stage.getViewport().getWorldHeight() - 3);
}
2021-04-09 12:53:55 +00:00
@Override
2021-04-22 15:43:41 +00:00
public void act(float dt) {
super.act(dt);
2021-04-09 12:53:55 +00:00
frameRate = Gdx.graphics.getFramesPerSecond();
}
@Override
public void draw(Batch batch, float parentAlpha) {
super.draw(batch, parentAlpha);
if (getDebug()) GameScreen.fontDebug.draw(batch, getInfo(), getX(), getY());
}
2021-04-13 19:08:25 +00:00
protected String getInfo() {
return frameRate + " fps";
2021-04-09 12:53:55 +00:00
}
}