Skip to content

Instantly share code, notes, and snippets.

@Phonbopit
Created May 24, 2014 06:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Phonbopit/961f45fdfa6abf9c067b to your computer and use it in GitHub Desktop.
Save Phonbopit/961f45fdfa6abf9c067b to your computer and use it in GitHub Desktop.
LibGDX Tutorial - Hello World , Link : http://devahoy.com/2014/04/libgdx-tutorial-hello-world/
public class AndroidLauncher extends AndroidApplication {
@Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
initialize(new MyGame(), config);
}
}
public class DesktopLauncher {
public static void main (String[] arg) {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
config.title = "Learn LibGDX #2 - Hello World ";
config.width = 500;
config.height = 500;
new LwjglApplication(new MyGame(), config);
}
}
import com.badlogic.gdx.ApplicationListener;
public class MyGame implements ApplicationListener {
@Override
public void create() {
}
@Override
public void resize(int width, int height) {
}
@Override
public void render() {
}
@Override
public void pause() {
}
@Override
public void resume() {
}
@Override
public void dispose() {
}
}
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
public class MyGame extends ApplicationAdapter {
SpriteBatch batch;
Texture img;
@Override
public void create () {
batch = new SpriteBatch();
img = new Texture("badlogic.jpg");
}
@Override
public void render () {
Gdx.gl.glClearColor(1, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
batch.draw(img, 0, 0);
batch.end();
}
}
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
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 MyGame extends ApplicationAdapter {
SpriteBatch batch;
Texture img;
BitmapFont font;
@Override
public void create () {
batch = new SpriteBatch();
img = new Texture("badlogic.jpg");
font = new BitmapFont();
font.setColor(Color.WHITE);
}
@Override
public void render () {
Gdx.gl.glClearColor(0, 1, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
// batch.draw(img, 0, 0);
font.draw(batch, "Hello World", 300, 300);
batch.end();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment