Lua tables vs Corona display groups

Hi all,

 
I have a question about Corona Display Groups versus normal lua tables.

 
The case is we are creating an object and inserting it into a table. (versus creating and image and inserting it to a Display Group)

 
 
 

-- In lua: myVariable = "My String Is here" -- x kb memory used myTable = {} table.insert(myTable, myVariable) -- 2x kb memory used AND myVariable and myTable[1] are different variables -- In Corona myImage = display.newImage( "image.png") -- (1) -- x kb texture memory used myDisplayGroup = display.newGroup() -- myDisplayGroup:insert(myImage) -- still x kb texture memory used -- myDisplayGroup[1] and myImage are the same thing (but in lua they differ) what happened to first myImage variable definition @1, how did they come together?  

 

 
I think there is some differences between lua tables and corona display groups’ tables.

 
Any comments about this situation?

 
Thank You.

Hello @aclk,

You’re correct in that Corona display groups are essentially Lua tables, and yet some methods that you’d use with tables like “table.insert()” can not be used with display groups. Instead, you need to use the Corona-supplied methods to handle insertion and removal of objects into display groups, i.e. “group:insert()”, or simply the “inline” method.

Similarly, you can’t query the number of objects in a display group with the “#group” notation… instead, you need to use “group.numChildren”.

All of this is outlined in this guide:

http://docs.coronalabs.com/guide/media/displayObjects/index.html

Hope this helps,

Brent

Hello @aclk,

You’re correct in that Corona display groups are essentially Lua tables, and yet some methods that you’d use with tables like “table.insert()” can not be used with display groups. Instead, you need to use the Corona-supplied methods to handle insertion and removal of objects into display groups, i.e. “group:insert()”, or simply the “inline” method.

Similarly, you can’t query the number of objects in a display group with the “#group” notation… instead, you need to use “group.numChildren”.

All of this is outlined in this guide:

http://docs.coronalabs.com/guide/media/displayObjects/index.html

Hope this helps,

Brent