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\$

1 Answer 1

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, 2016 at 20:47
  • \$\begingroup\$ @Asaltaviejas Glad I could help. \$\endgroup\$
    – bornander
    Jan 19, 2016 at 22:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .