标题中的主题
加载纹理,制作
private static Map<String, Texture> textureAlreadyLoad = new HashMap<String, Texture>();
加载源
String location = tagMap.get("location");
Texture texture;
if(textureAlreadyLoad.containsKey(location)) {
texture = textureAlreadyLoad.get(location);
} else {
texture = new Texture(Gdx.files.internal(location));
textureAlreadyLoad.put(location, texture);
}
graphic = new StaticGraphic(state, new TextureRegion(texture));
支持班
public class GraphicStorage {
private Map<Pair<String, State>, ActorGraphic> ActorsGraphic;
public GraphicStorage() {
ActorsGraphic = ResourceProvider.getMapGraphic();
}
public ActorGraphic getGraphic(String className, State state) {
return ActorsGraphic.get(new Pair<String, State>(className, state));
}
}
然后我只是用 spriteBatch 绘制它——只有 64x64 白色矩形(图像大小) 这是我使用一个图像的一点。
在地图中存储纹理好不好?