2
\$\begingroup\$
AssetManager manager = new AssetManager();

manager.load("texture1", Texture.class); 
manager.load("texture2", Texture.class);
manager.load("texture3", Texture.class);
//And so on...

And then I load it from another screen, do I still have to dispose it? Or manager does it when I call manager.clear?

\$\endgroup\$
2
\$\begingroup\$

You shouldn't call dispose directly on a Texture loaded by an AssetManager, they are disposed the the AssetManager is cleared or disposed or if you call unload on the AssetManager and pass the Texture.

The reason you shouldn't dispose assets from an AssetManager is that they can be shared between many other assets (two fonts may use the same texture for example) and the AssetManager tracks this by reference counting them so that even if you call unload for a texture it will not get unloaded until you also unload the dependant assets.

\$\endgroup\$
2
  • \$\begingroup\$ Oh, in my game i have a bullet entity, when it dies i call dispose on the texture, that's why it seems like a black square after it, thanks! \$\endgroup\$ Jan 19 '16 at 20:47
  • \$\begingroup\$ @Asaltaviejas Glad I could help. \$\endgroup\$
    – bornander
    Jan 19 '16 at 22:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.