Reputation:
I've been having trouble using the Gdx.files.internal() from libgdx; it seems that every time I run it as a desktop application i get this main error:
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: File not found: \data\sounds\music\mainmusic.mp3 (Internal) at com.badlogic.gdx.files.FileHandle.read(FileHandle.java:136) at com.badlogic.gdx.backends.lwjgl.audio.Mp3$Music.(Mp3.java:42) ... 10 more
I've read 5 separate threads in the matter, one of which seemed like was the most likely problem so I've tried...
my complete path is in /Flipcrew Legends-desktop/assets/data/sounds/music/mainmusic.mp3
public class SplashScreen implements Screen{
final FlipcrewLegends game;
Texture splashTexture;
Sprite splashSprite;
SpriteBatch batch;
TweenManager manager;
Music introMusic;
public SplashScreen(FlipcrewLegends game) {
this.game = game;
introMusic = Gdx.audio.newMusic(Gdx.files.internal("data/sounds/music/mainmusic.mp3"));
introMusic.setLooping(true);
}
This However... seems to be working..
@Override
public void show() {
splashTexture = new Texture("data/images/main/splash.png");
splashTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
splashSprite = new Sprite(splashTexture);
splashSprite.setColor(1, 1, 1, 0);
}
path: /Flipcrew Legends-desktop/assets/data/images/main/splash.png
// Rest of class is omitted b/c it doesn't seem necessary (I can add it if requested)
//unfortunately, Gdx.audio.newMusic doesnt seem to have a direct string path method so I couldn't try that out
Additional Info: -> I've tried copying the assets folder in the desktop folder from core to no avail (deleted after) -> One thread said that libgdx usually takes the data from the android folder and then applies it to the desktop (unfortunately I started with only the desktop, no android) but I'm guessing libgdx has been nightly updated since the last date of that post, maybe an alternative has been added for that?
edit:
Just now after reverting assets/data/etc.... into assets/etc.....
even the new Texture(path);
is getting the same error - still doesn't work... retried methods above, will restart the computer after posting, might be a compiling issue.
restarted computer, no difference
Upvotes: 11
Views: 21500
Reputation: 1
I had a same problem on Android Studio. I applied direct path for every each asset.
"C:\Users\Admin\Desktop\test1\android\assets/starfish.png"
enter public void create()
{
batch = new SpriteBatch();
turtleTexture = new Texture( Gdx.files.internal("C:\\Users\\Admin\\Desktop\\test1\\android\\assets/starfish.png") );
turtleX = 20;
turtleY = 20;
turtleRectangle = new Rectangle( turtleX, turtleY,
turtleTexture.getWidth(), turtleTexture.getHeight() );
starfishTexture = new Texture( Gdx.files.internal("C:\\Users\\Admin\\Desktop\\test1\\android\\assets/starfish.png") );
starfishX = 380;
starfishY = 380;
starfishRectangle = new Rectangle( starfishX, starfishY,
starfishTexture.getWidth(), starfishTexture.getHeight() );
oceanTexture = new Texture( Gdx.files.internal("C:\\Users\\Admin\\Desktop\\test1\\android\\assets/water.jpg") );
winMessageTexture = new Texture( Gdx.files.internal("C:\\Users\\Admin\\Desktop\\test1\\android\\assets/you-win.png") );
win = false;
}
Upvotes: -1
Reputation: 79
Answer is for outside of LibGDX, since someone already answered the original question. The answer may help with related efforts with files outside of LibGDX.
Assumption:
Packages exist ... Apple, Orange, Grape. Trying to use relative paths.
Access the files in the format, ...
Upvotes: 1
Reputation: 173
What worked for me is, I had to go into assets->Build Path -> Configure Inclusion/Exclusion. I had to add all of my needed folders and files into the Inclusion section.
Upvotes: 2
Reputation: 749
Try "cleaning" your project by going to Project-> Clean. Also try "refreshing" your libGDX desktop folder by right clicking and using Gradle-> Refresh All
libGDX uses linked folders. You only need to copy the file to one of your asset folders (do this in eclipse, not in file explorer.)
Upvotes: 5