I'm following this tutorial on libgdx and I've hit a bit of a snag. I just finished the 'loading the assets' section. When I tried to run it, instead of getting the rain sound and a pink background, like the tutorial claims, I get errors up the wazoo. Here's my Drop.java:
package com.badlogic.drop;
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.Texture;
public class Drop implements ApplicationListener {
Texture dropImage;
Texture bucketImage;
Sound dropSound;
Music rainMusic;
@Override
public void create() {
// load the images for the droplet and the bucket, 64x64 pixels each
dropImage = new Texture(Gdx.files.internal("droplet.png"));
bucketImage = new Texture(Gdx.files.internal("bucket.png"));
// load the drop sound effect and the rain background "music"
dropSound = Gdx.audio.newSound(Gdx.files.internal("drop.wav"));
rainMusic = Gdx.audio.newMusic(Gdx.files.internal("rain.mp3"));
// start the playback of the background music immediately
rainMusic.setLooping(true);
rainMusic.play();
}
@Override
public void dispose() {
}
@Override
public void render() {
Gdx.gl.glClearColor(1, 1, 1, 1);
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
}
@Override
public void resize(int width, int height) {
}
@Override
public void pause() {
}
@Override
public void resume() {
}
}
and here are my errors. (Ones I think are important are bolded)
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: droplet.PNG at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:113) Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: droplet.PNG at com.badlogic.gdx.graphics.Pixmap.(Pixmap.java:140) at com.badlogic.gdx.graphics.glutils.FileTextureData.prepare(FileTextureData.java:64) at com.badlogic.gdx.graphics.Texture.load(Texture.java:175) at com.badlogic.gdx.graphics.Texture.create(Texture.java:159) at com.badlogic.gdx.graphics.Texture.(Texture.java:133) at com.badlogic.gdx.graphics.Texture.(Texture.java:122) at com.badlogic.drop.Drop.create(Drop.java:21) at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:127) at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:110) Caused by: com.badlogic.gdx.utils.GdxRuntimeException: File not found: droplet.PNG (Internal) at com.badlogic.gdx.files.FileHandle.read(FileHandle.java:127) at com.badlogic.gdx.files.FileHandle.length(FileHandle.java:580) at com.badlogic.gdx.files.FileHandle.readBytes(FileHandle.java:215) at com.badlogic.gdx.graphics.Pixmap.(Pixmap.java:137) ... 8 more
The weird thing is, I have all of the pngs and music files in my assets/data folders. They're all there, but the code isn't seeing them. Any idea what's causing this?
assets/data
, try usingdropImage = new Texture(Gdx.files.internal("data/droplet.png"));
– Vikram