Actually, the top part can be simplified to:
local ballTable = {}
---------
-- Ball 1 .. n
-- If you dont need to reference ball1Layer1..x
-- elsewhere in the code, you really dont even need
-- ball1Layer1..x local variables, since you can
-- assign the group to add the new object to directly in the
-- display.newImage() call.
---------
for i = 1, 10 do
ballTable[i] = display.newGroup()
local ball1Layer1 = display.newImage(ballTable[i],"ballLayer1.png")
local ball1Layer2 = display.newImage(ballTable[i],"ballLayer2.png")
allBallsGroup:insert( ballTable[i] )
end
Now, this next part, Im not quite sure of. I dont know if moving the group actually moves the objects inside of it:
for i = 1, 10 do
allBallsGroup[i].x = i + 30
allBallsGroup[i].y = i + 120
end
You may have do put the x,y coordinates on ball1Layer1 and ball1Layer2 up above where you declair ball1Layer1…x:
ball1Layer1.x = i + 30
ball1Layer2.x = i + 30
ball1Layer1.y = i + 120
ball1Layer2.y = i + 120
or you can put the coords directly in the newImage call:
local ball1Layer1 = display.newImage(ballTable[i],"ballLayer1.png", i+30, i + 120 )
local ball1Layer2 = display.newImage(ballTable[i],"ballLayer2.png", i+30, i + 120 )
Anyway, as for them not showing up, how is allBallsGroup defined? Is it perhaps isVisible = false? Does it belong to a group that perhaps is isVisible = false?
To test to see if the groups are invisible or something, remove the part where you actually add the display.newImage() to a group:
--Not assigning these display.newImages to a group,
--so they should show up on the top of the screen,
--unless there is something else rendering on top of
--them later in the code.
for i = 1, 10 do
--ballTable[i] = display.newGroup()
local ball1Layer1 = display.newImage("ballLayer1.png",50,50)
local ball1Layer2 = display.newImage("ballLayer2.png",50,50)
--allBallsGroup:insert( ballTable[i] )
end
[import]uid: 8541 topic_id: 2750 reply_id: 8270[/import]