Search code examples
androidfilepathlibgdxassets

when to use gdx.files.internal and when relative path?


I've seen many examples of both cases, for example:

atlas = new TextureAtlas("skins/userInterface.pack");
white = new BitmapFont(Gdx.files.internal("font/white.fnt"));

I've seen that on a tutorial but, it also works that way:

atlas = new TextureAtlas(Gdx.files.internal("skins/userInterface.pack"));
white = new BitmapFont("font/white.fnt");

when should I use Gdx.files.internal or directly the relative path from assets folder?


Solution

  • It is exactly the same. When using a String parameter, the constructor uses Gdx.files.internal to resolve the file, just as you would do it yourself.

    You can see this here for example in case of the TextureAtlas.