LibGDX AssetManager的正确使用方法

LibGDX the correct way of using AssetManager

里面Managing your assets据说下面的编码会出问题 public static AssetManager assets = new AssetManager(); 但是我不明白上面代码和下一个代码之间的区别:

public class AssetSingleton {    
    private static final AssetSingleton instance = new AssetSingleton();

    private final AssetManager assets = new Assets();

    public AssetManager getAssets(){
        return assets;
    }
}

...........................................

AssetManager manager = AssetSingleton.instance.getAssets();

那么为什么 pausing/resuming android 应用程序的第一个代码不安全? 我必须在哪里以及以什么方式存储 AssetManager 实例? LibGDX 文档中没有示例。 在“学习 LibGDX 游戏开发第 2 版”一书中,使用了带有 assetmanager 实例的单例以及 resume/pause 这个单例 loads/unloads 资源。

Managing your assets中也说:

If you don't set the AssetManager as shown in the last snippet, the usual managed texture mechanism will kick in, so you don't have to worry about anything.

我是否理解正确:如果我没有单例并且我不使用 AssetManager 的静态实例 - 资产将由 LibGDX 自动加载和卸载。如果是这样 - 怎么样?有什么区别?

  1. 静态引用资产尤其糟糕,因为静态的生命周期可能与创建资源的上下文的生命周期不同。检查这个详情

  2. 如果你想在恢复游戏时显示加载屏幕,你必须使用

    Texture.setAssetManager(manager);
    

    If you don't set the AssetManager as shown in the above statement, the usual managed texture mechanism will kick in, so you don't have to worry about anything.