From efe5635e0522b46e9b26d7265c33dfce5921b56c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laure=CE=B7t?= Date: Fri, 9 Apr 2021 14:53:55 +0200 Subject: [PATCH] feat: added FPS counter --- core/src/sagittarius/model/FPS.java | 31 +++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 core/src/sagittarius/model/FPS.java diff --git a/core/src/sagittarius/model/FPS.java b/core/src/sagittarius/model/FPS.java new file mode 100644 index 0000000..f25b924 --- /dev/null +++ b/core/src/sagittarius/model/FPS.java @@ -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); + } + +}