【发布时间】:2014-04-09 15:53:03
【问题描述】:
我正在尝试从 skin.json 加载 libgdx 中的简单皮肤。皮肤文件非常简单:
{
com.badlogic.gdx.graphics.g2d.Sprite : {
centerImage : {
}
}
}
使用此代码,代码运行良好,但我得到一个空精灵。尝试加载纹理并加载纹理化的精灵,加载纹理时出现异常:
{
com.badlogic.gdx.graphics.Texture : {
centerImageTexture : {
file : images/crop001.png
}
},
com.badlogic.gdx.graphics.g2d.Sprite : {
centerImage : {
texture : centerImageTexture
}
}
}
这是 libGDX 代码
skin = new Skin(Gdx.files.internal(skinFile));
centralImage = skin.getSprite("centerImage");
我需要一种在不使用图集的情况下将纹理定义到皮肤文件中的方法。文档解释了如何加载纹理:
Texture texture = skin.get("logo", Texture.class);
但我找不到定义它的方法
谢谢!!
【问题讨论】:
-
我认为您可以通过调试轻松找到原因
-
我想我知道发生了什么。我将问题编辑得更清楚。