Hi guys, I was just wondering if anyone else has come across this issue. I'm working on a game that uses different sprite sheets for different stages. Currently I have one instance of the AssetManager that the different states of the game uses to load the assets that it needs. For example the menu screen loads the sprite sheet that it needs and then when the game screen is created it has the AssetManager dispose it's data and loads the sprite sheet for the game. In the game I have different sprite sheets that are loaded at different times depending on what stage of the game they are in. To help manage memory I was planning on having the AssetManager load and unload data as needed. The problem that I'm having is when I call removeTexure it doesn't actually get disposed. The memory stays the same and I can still recreate textures after calling it. Any help would be greatly appreciated. Thanks
AssetManager removeTexture not working how I'd expect using ATF sprite sheet(5 posts) (3 voices)
Since you mentioned you were using sprite sheets, remember that the only way textures will actually get disposed is if you call removeTextureAtlas(_). If you are calling removeTexture() on individual textures from an atlas, remember that when using a sprite sheet, there is only *one* texture, and that is the texture of the atlas itself, and you can't dispose GPU memory on just disposing SubTexture instances from an atlas, you can only dispose the atlas itself, and also of course, only when you aren't actively using any textures from the atlas in your active screen.
Thanks for the quick response Jeff! I figured it out. I was calling removeTextureAtlas but I was passing it the wrong name. My xml file was named 'ddGameAtlas.xml' and the ATF file was named 'ddGame.atf'. The problem was that I was calling removeTextureAtlas("ddGameAtlas") when it should have been removeTextureAtlas("ddGame"). I noticed that in the output window it displayed "[AssetManager] Adding texture atlas 'ddGame'". Not sure why it didn't add it as ddGameAtlas, but once I changed that it worked just fine. Sorry to take up anyone's time.
Starling is awesome!
Good to know it was something simple.
Yes, AssetManager registers an atlas by using the base name of the "imagePath" attribute that is defined inside the atlas xml.
Great to hear you solved the problem -- and thanks a lot for the nice "PS"!
You must log in to post.