feat: added FPS counter
This commit is contained in:
parent
eecefbe8a5
commit
efe5635e05
31
core/src/sagittarius/model/FPS.java
Normal file
31
core/src/sagittarius/model/FPS.java
Normal 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);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue