Now my Image isn't loading to the screen. I tried to be decorative with the code but since it isn't working I made it just like the video I'm whatching. I don't get any exceptions, but the image doesn't appear still.
My main desktop launcher class:
public class DesktopLauncher {
public static void main (String[] arg) {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
config.title = " Game Tests ";
config.width = 500;
config.height = 400;
config.useGL30 = true;
new LwjglApplication(new MyGdxGame(), config);
}
}
My Game class:
public class MyGdxGame extends Game {
@SuppressWarnings("unused")
private TestScreenA GameScreen;
@Override
public void create () {
//loads image
AssetLoaderTest.load();
GameScreen = new TestScreenA(this);
}
@Override
public void render () {
}
}
My Screen class:
public class TestScreenA implements Screen{
@SuppressWarnings("unused")
private MyGdxGame game;
//Camera
private OrthographicCamera camera;
//images etc.
private SpriteBatch batch;
public TestScreenA(MyGdxGame game) {
this.game = game;
//Camera
camera = new OrthographicCamera();
camera.setToOrtho(false, 1920, 1080);
batch = new SpriteBatch();
}
public void render(float delta) {
//clears the screen with white
Gdx.gl.glClearColor(1F, 1F, 1F, 1F);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
camera.update();
//loads images scaled to camera
batch.setProjectionMatrix(camera.combined);
batch.begin();
batch.draw(AssetLoaderTest.s, 0, 0);
batch.end();
}
public void resize(int width, int height) {
}
public void show() {
}
public void hide() {
}
public void pause() {
}
public void resume() {
}
public void dispose() {
}
}
My AssetLoaderTest class:
public class AssetLoaderTest {
//Images etc.
public static Texture t;
public static Sprite s;
static void load() {
t = new Texture(Gdx.files.internal("testImgs/badlogic.jpg"));
//Automatically scales texture based off of window size
t.setFilter(TextureFilter.Linear, TextureFilter.Linear);
//a sprite is pretty much the body and the texture is the texture or image of it
s = new Sprite(t);
s.flip(false, true);
}
}