我需要在我的项目中使用图集文件。 但 libgdx 只会给我一个文件未找到的错误,即使我已经在 Assets 文件夹中包含了图集。
这是代码:
https://github.com/cristianceron/CharacterEditor/blob/master/core/src/gui/GUI.java
LoadAtlas.addListener(new InputListener()
{
@Override
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
character.AddAnimation(AtlasName.getText());
return true;
}
});
https://github.com/cristianceron/CharacterEditor/blob/master/core/src/gui/Chara.java
public void AddAnimation(String s)
{
chara_atlas.AddAnimation(s);
}
https://github.com/cristianceron/CharacterEditor/blob/master/core/src/character/Character_Atlas.java
public void AddAnimation(String name)
{
if (Gdx.files.internal(name).exists())
{
TextureAtlas tmp = new TextureAtlas(Gdx.files.internal(name));
texture_atlases.add(tmp);
animations.add(new Animation(1/15f, texture_atlases.get(texture_atlases.size()-1).getRegions()));
}
else
{
Gdx.app.log("File", "File Not found " + name);
}
}
编辑:链接到我的项目 github 存储库: https://github.com/cristianceron/CharacterEditor
链接到 Assets 文件夹: https://github.com/cristianceron/CharacterEditor/tree/master/android/assets
最佳答案
感谢 IRC 人员,我的错误是使用带有变量的 Gdx.files.internal 而不是使用 Gdx.files.local。
我真傻。
关于java - Libgdx file.internal 文件未找到错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34108184/