I am having trouble rendering a simple texture to the screen using LibGDX, what am I missing here? Everywhere I look the same method is used, but every time I run, I get: Exception in thread “LWJGL Application” com.badlogic.gdx.utils.GdxRuntimeException: Couldn’t load file: data/background.png
It’s one class, so nothing fancy, I don’t know what I’m doing wrong.
package com.pixelPower.space;
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
public class Game implements ApplicationListener {
public static int WIDTH;
public static int HEIGHT;
public static OrthographicCamera camera;
private Texture texture;
private SpriteBatch batch;
public void create() {
WIDTH = Gdx.graphics.getWidth();
HEIGHT = Gdx.graphics.getHeight();
batch = new SpriteBatch();
texture = new Texture(Gdx.files.internal("data/background.png"));
camera = new OrthographicCamera(WIDTH, HEIGHT);
camera.translate(WIDTH / 2, HEIGHT / 2);
camera.update();
}
public void render() {
Gdx.gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
batch.begin();
batch.draw(texture, 0, 0);
batch.end();
}
public void resize(int width, int height) {
}
public void pause() {
}
public void resume() {
}
public void dispose() {
}
}