Add FPS counter
This commit is contained in:
parent
48b2e8b96b
commit
add8b5670b
2 changed files with 18 additions and 1 deletions
|
@ -1,25 +1,43 @@
|
|||
package dev.bangbang.loom;
|
||||
|
||||
import com.badlogic.gdx.ApplicationAdapter;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.OrthographicCamera;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||
import com.badlogic.gdx.utils.ScreenUtils;
|
||||
|
||||
public class Game extends ApplicationAdapter {
|
||||
SpriteBatch batch;
|
||||
Texture img;
|
||||
BitmapFont font;
|
||||
OrthographicCamera camera;
|
||||
|
||||
@Override
|
||||
public void create () {
|
||||
batch = new SpriteBatch();
|
||||
img = new Texture("badlogic.jpg");
|
||||
font = new BitmapFont();
|
||||
camera = new OrthographicCamera();
|
||||
camera.setToOrtho(false, 1600, 900);
|
||||
|
||||
font.getData().setScale(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render () {
|
||||
ScreenUtils.clear(1, 0, 0, 1);
|
||||
|
||||
camera.update();
|
||||
batch.setProjectionMatrix(camera.combined);
|
||||
|
||||
batch.begin();
|
||||
|
||||
batch.draw(img, 0, 0);
|
||||
font.draw(batch, "FPS: " + Integer.toString(Gdx.graphics.getFramesPerSecond()), 5, 895);
|
||||
|
||||
batch.end();
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@ public class DesktopLauncher {
|
|||
Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
|
||||
config.setWindowedMode(1600, 900);
|
||||
config.setForegroundFPS(60);
|
||||
config.setIdleFPS(15);
|
||||
config.useVsync(true);
|
||||
config.setTitle("Loom");
|
||||
new Lwjgl3Application(new Game(), config);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue