Hi Guys
I've been searching the forum for an answer to this topic and found this
http://giderosmobile.com/forum/discussion/1775/texture-pack-loading-unloading/p1Is the Atlas I load still going to 'unload' after I exit the level, if I use ...
function Scene1:init()
self.pack = TexturePack.new("media/menus.txt", "media/menus.png")
end |
... instead of making 'pack' local?
Thank you in advance for any help
Comments
If you want to force unloading, then set self.pack = nil
do the same for any other references to pack (for example all bitmaps that use pack texture) and it will be garbage collected after that.
You can also force garbage collection by calling collectgarbage("collect") a view times, but only after you freed the references to your pack
Thank you, your explanation helps
It sound like everything is pretty automatic.
Basically, I want to use a different atlas for every level, but don't want to overload the device by loading them all at once.
Sound like, as long as I load my Atlas inside the scenes init, every should be fine.
I created an atlas loader for my game, using the global space, so I could keep some atlases loaded. I have one function to load atlases and another to remove atlases.
Some example uses are an atlas containing interface elements should not be loaded each level. Or if they 'retry' a level, the atlas for that level should not be loaded again. As @ar2rsawseen mentions, if you don't use global, they will be collected when the scene changes.
It cut down load times dramatically!
Here's my setup.
Im my main.lua I have:
- In these functions, index is the table number in atlasHolder where the atlas will be stored.
- name is the name of the atlas file eg atlas 1.png
- Also note that in this part of the code:
- I'm storing my atlas files in a folder in my Gideros project called Atlases/
Then when I want to load an atlas I have this, at the start of the scene:
atlasHolder[6] , atlasHolder['Mud Tileset'] etc...
Thank you heaps for the detailed reply, it's really helpful
I will have a good play around with Atlas loading/unloading and post the progress.
Thanks again!