我需要在项目中使用atlas文件。 但libgdx只给我一个文件未找到错误,即使我已经在资产文件夹中有图册。
这是代码:
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 repo: https://github.com/cristianceron/CharacterEditor
链接到assets文件夹: https://github.com/cristianceron/CharacterEditor/tree/master/android/assets
答案 0 :(得分:2)
感谢IRC人员,我的错误是使用Gdx.files.internal和变量,而不是使用Gdx.files.local。
愚蠢的我。