原图
绘制
package com.xuefei.mygame;
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle;
public class MyGame implements ApplicationListener {
Stage stage;
SpriteBatch batch;
Texture test;
@Override
public void create() {
float w = Gdx.graphics.getWidth();
float h = Gdx.graphics.getHeight();
stage = new Stage(w, h, true);
LabelStyle labelStyle = new LabelStyle(new BitmapFont(), Color.WHITE);
Label label = new Label("FPS:", labelStyle);
label.setName("fpsLabel");
label.setY(0);
label.setX(w - label.getTextBounds().width);
stage.addActor(label);
batch = new SpriteBatch();
test = new Texture(Gdx.files.internal("assets/test.png"));
}
@Override
public void dispose() {
stage.dispose();
}
@Override
public void render() {
Gdx.gl.glClearColor(0, 0, 0, 0);
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
Label label = (Label) stage.getRoot().findActor("fpsLabel");
label.setText("FPS:" + Gdx.graphics.getFramesPerSecond());
label.setX(800 - label.getTextBounds().width);
stage.act();
stage.draw();
batch.begin();
batch.draw(test, 0,0);
batch.end();
}
@Override
public void resize(int width, int height) {
}
@Override
public void pause() {
}
@Override
public void resume() {
}
}