Hello there!
I’m developing my first game with Corona, and I have some questions about memory usage and disposal.
I’ve created classes for each graphic element of the game (bullets, enemies, etc).
Inside those classes, the actual graphic elements (images, sprites, etc) are created and disposed by constructor and destructor methods that are invoked as game evolves.
The question is about the instances of the classes, given that references are mantained for the graphical elements, but not for them.
For example a class “bullet” that have inside it a graphical image. The image is created and added to screen group on construction method, and is removed from screen group, released (with removeSelf) and set with “nil” on destructor method.
But the “bullet” class itself is created locally by method “fire” and is not hold at any place (like a list), nor is it released after the destructor is invoked.
The question is: do I need to keep a list with the references of all those classes so them don’t get garbage collected while they are still being used (remember that they are created locally and that there is only external references for the graphical elements inside those classes, and not for them)?
Maybe I need to keep this list to have condition to set the reference to “nil” of those classes as well, right?
Thanks a lot and best regards,
Mauro.