title: Reloading assets on resume
body: <p>I'm working in an Android game using libGDX framework while a learn from their wiki and <a href="https://rads.stackoverflow.com/amzn/click/com/1782166041" rel="nofollow noreferrer" rel="nofollow noreferrer">Learning Libgdx Game Development</a> book. The author of the book defines an Assets class to load game assets using an AssetManager. Every time the game is resumed the assets need to be reloaded so he use a call to Assets.intance.init(new AssetManager()) what reload the assets and create new objects to store textures references.</p>
  
  <p>When I do this in my game, after resume, all I have are black boxes where I had nice textures so I suppose that the problem here is that I'm using the old references. I put here part of the code from the book:</p>
  
  <p><strong>AssetManager#init</strong></p>
  
  <pre><code>public void init(AssetManager assetManager) {
  
      /* Dispose previous asset manager */
      if (this.assetManager != null) {
          this.assetManager.dispose();
      }
  
      this.assetManager = assetManager;
  
      assetManager.setErrorListener(this);
      assetManager.load(Constants.TEXTURE_ATLAS, TextureAtlas.class);
  
      /* Start loading assets and wait until finished */
      assetManager.finishLoading();
  
      Array&lt;String&gt; assetNames = assetManager.getAssetNames();
      Gdx.app.debug(TAG, "Assets loaded: " + assetNames.size);
      for (String assetName : assetNames) {
          Gdx.app.debug(TAG, "Asset: " + assetName);
      }
  
      TextureAtlas atlas = assetManager.get(Constants.TEXTURE_ATLAS);
  
      /* Create game resource objects. Here I get what I need from the atlas */
      player = new AssetPlayer(atlas);
      enemy = new AssetEnemy(atlas);
  }
  </code></pre>
  
  <p>When I create my game objets I use Assets.instance.player and Assets.instance.enemy to store a reference to textures as the author of the book does so this could be the problem. The thing is that aftere re-read the book, I don't see how he solve this problem.</p>
  
  <p>I'm pretty sure that I can solve the problem changing references in my game objects but all is becoming so messy. My real question is, how should I manage game assets in my game? I've been searching a lot for game examples but most of them don't use an AssetManager but instead static variables to textures.</p>
  
  <p>Should I keep references of textures in game objects? It is really necessary to reload assets on resume? How could I reload textures in my game objects when all the objects are inside a worldController that don't know when a game is being resumed?</p>