【问题标题】:Libgdx - Using TextureAtlas with Skin. Memory Consideration?Libgdx - 使用带有皮肤的 TextureAtlas。内存考虑?
【发布时间】:2013-09-21 13:01:16
【问题描述】:

我正在使用 TextureAtlas 在 Libgdx 中加载我的游戏资源。我知道TextureAtlas 的方法findRegion 是昂贵的,内存明智的,所以它应该加载一次并存储。

我刚刚在Skin 类中遇到了这个例子:

TextureAtlas atlas = ...
Skin skin = new Skin();
skin.addRegions(atlas);
...
TextureRegion hero = skin.get("hero", TextureRegion.class);

这意味着我也可以使用 Skin 来获取我的纹理。我的问题是,Skin 类如何加载这些资产。它会在skin.addRegions(atlas); 上加载所有内容吗?还是 skin.get("hero", TextureRegion.class); 在每次调用时从 TextureAtlas 加载它,使其与 atlas.findRegion("hero") 调用一样昂贵?

我希望在游戏开始时从 TextureAtlas 加载我的所有资源。所以我在想我可以在皮肤中做一个简单的加载,然后从那里使用我的资产吗?

【问题讨论】:

    标签: memory libgdx assets texture-atlas


    【解决方案1】:

    从源代码看来,添加到Skin 的区域存储在Array 中,并在0.9.8 中通过字符串比较找到,就像它们在TextureAtlas 中一样。查找时间将相似。

    【讨论】:

    • 那么,如果我想在开始时从 TextureAtlas 加载我的所有资产,除了按名称一一加载之外别无选择?
    猜你喜欢
    • 1970-01-01
    • 2014-06-22
    • 2013-04-17
    • 2014-09-11
    • 2014-04-18
    • 2015-12-24
    • 2017-04-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多