Hello everyone,
As I'm approaching the release of my first game, I realize that there are a few things I'm still not clear on :S
Throughout the duration of the game, I have objects being created, then displayed in my in game "scene". In some cases, some objects are removed from the scene tree (like when a power up collides with the player). When I remove an object from the scene, is it removed from memory as well? How do I ensure that an object has been deleted completely, and not just invisible, but still kept track of by event listeners, etc. I know in C++ you would manage memory very closely, but with lua I have no idea how the automatic garbage collection functions, or how Gideros handles that stuff.
Ok, that was maybe a big question :P
Something else I am not sure how to best implement: I have music playing in different scenes, however when I set the device to sleep the music keeps playing. I would like the music to pause and resume as the user puts the device to sleep and wakes it up again.
I tried to add an event listener to a sound channel that would listen for Event.APPLICAITONSUSPEND (or whatever it's called) and run a function that would stop the channel. I also added similar listeners and functions to play the music again. This does not seem to work though. Is this an effective method to achieve what I want? Shall I continue down this path, or is there a better way to stop music upon device suspension?
As always, everyone's help is greatly appreciated!
Thanks,
Joel
Comments
SomeObject *myVar = SomeObject.new() <-- memory allocated
SomeObject *myVar = SomeObject.new() <-- more memory allocated, the above memory is never deallocated and is leaked.
Garbage collection is a part of the runtime that scans all memory and checks to see if any active variables are pointing to it. If nothing is pointing tnotices that the memory allocated the first time no longer has any references to it so the GC will deallocate it.
My apps: http://www.yummyyellow.com