[Updated August 4, 2020]
There’s a cool tutorial video (and sample code) on the Three Ring Ranch video course site. It’s free (although requires you register on the site) and talks about managing display objects that are “mass created” and don’t have variable names attached to them.
For example, in a loop like this:
for x = 1, 10 do
local foo = display.newImage("alien.png")
…you’ll end up with 10 alien objects on the screen, but no way to access them because the “foo” variable was reused each time.
Why doesn’t the next version of the loop overwrite the first display object?
And even if you DO end up with 10 aliens on the screen, how can you access them if they don’t have variable names?
That’s what the Solar2D tutorial video and sample code cover.
Click that link, register (or sign in if you already have an account there) and check it out!
Originally written for Corona SDK which is now called Solar2D, but is still the easiest way to get started making your own 2D games!