Layar 1
import com.badlogic.gdx.*;
import com.badlogic.gdx.graphics.*;
import com.badlogic.gdx.graphics.g2d.*;
public class MyGdxGame extends Game{
SpriteBatch batch;
BitmapFont font;
@Override
public void create(){
batch = new SpriteBatch();
font = new BitmapFont();
font.setColor(Color.RED);
font.setScale(2);}
@Override
public void render(){
//warna background
Gdx.gl.glClearColor(1, 1, 1, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
//tata letak text ganti X dan Y dengan angka
font.draw(batch, "tap dimana saja untuk pindah layar", 0, 400);
batch.end();
if(Gdx.input.isTouched()){
this.setScreen(new MainMenuScreen(this));}
super.render();}
@Override
public void dispose(){
batch.dispose();
font.dispose();}
@Override
public void resize(int width, int height){}
@Override
public void pause(){}
@Override
public void resume(){}
}
Layar 2
import com.badlogic.gdx.*;
import com.badlogic.gdx.graphics.*;
import com.badlogic.gdx.graphics.g2d.*;
import javax.microedition.khronos.opengles.*;
public class MainMenuScreen implements Screen{
final MyGdxGame game;
SpriteBatch batch;
Texture image;
TextureRegion imageRegion;
OrthographicCamera camera;
public MainMenuScreen(final MyGdxGame game){
this.game = game;}
@Override
public void show(){
camera = new OrthographicCamera();
camera.setToOrtho(false, 800, 480);
image=new Texture(Gdx.files.internal("android.jpg"));
imageRegion=new TextureRegion(image,0,0,1000,1000);
batch=new SpriteBatch();}
@Override
public void render(float p1){
Gdx.gl.glClearColor(1, 1, 1, 1);
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
batch.begin();
batch.draw(imageRegion,0,0,200, 200);
batch.end();}
@Override
public void resize(int p1, int p2){}
@Override
public void hide(){}
@Override
public void pause(){}
@Override
public void resume(){}
@Override
public void dispose(){}
}