我需要在我的项目中使用图集文件。但是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存储库:https://github.com/cristianceron/CharacterEditor
到资产文件夹的链接:https://github.com/cristianceron/CharacterEditor/tree/master/android/assets
多亏了IRC的人,我的错误是将Gdx. files.内部与变量一起使用,而不是使用Gdx.files.local。
我真傻。