Created
May 24, 2014 06:27
-
-
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/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AndroidLauncher extends AndroidApplication { | |
@Override | |
protected void onCreate (Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration(); | |
initialize(new MyGame(), config); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() { | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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