Skip to content

Instantly share code, notes, and snippets.

@mrp1q7z
Last active August 29, 2015 14:05
Show Gist options
  • Save mrp1q7z/58d1c42a2613ebff94ac to your computer and use it in GitHub Desktop.
Save mrp1q7z/58d1c42a2613ebff94ac to your computer and use it in GitHub Desktop.
libGDX sample
package name.taoka.ugeee.hellogdx;
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
public class GdxMain extends ApplicationAdapter {
SpriteBatch batch;
Texture img;
private BitmapFont font; // @@@
@Override
public void create() {
batch = new SpriteBatch();
img = new Texture("badlogic.jpg");
font = new BitmapFont(); // @@@
font.setColor(Color.RED); // @@@
}
@Override
public void render() {
Gdx.gl.glClearColor(1, 1, 1, 1); // @@@(R=1,G=1,B=1,Alpha=1)
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
batch.draw(img, 0, 0);
font.draw(batch, "Hello GDX", 300, 400); // @@@
batch.end();
}
// @@@ add
@Override
public void dispose() {
batch.dispose();
font.dispose();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment