feat: added FPS counter

This commit is contained in:
Laureηt 2021-04-09 14:53:55 +02:00
parent eecefbe8a5
commit efe5635e05

View file

@ -0,0 +1,31 @@
package sagittarius.model;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.scenes.scene2d.Actor;
import sagittarius.SagittariusGame;
public class FPS extends Actor {
// ---------- ATTRIBUTEs ----------
private BitmapFont font = new BitmapFont();
private int frameRate;
// ---------- METHODs ----------
@Override
public void act(float delta) {
super.act(delta);
frameRate = Gdx.graphics.getFramesPerSecond();
}
@Override
public void draw(Batch batch, float parentAlpha) {
super.draw(batch, parentAlpha);
font.draw(batch, frameRate + " fps", 3, SagittariusGame.getActiveScreen().getUIStage().getViewport().getWorldHeight() - 3);
}
}