This is my first post! Ive been happily plugging away with Corona for while now, and have run into a bit of a wall. Heres what I want to do: I have spawns that consist of several rects in a group. The spawns are kept in a table. After the spawn is generated I want to go back in and apply fills to the rectās as necessary. How can I āpointā to these nested elements? Any help would be awesome! Here is a simplified version of the code Ive been using to experiment on:
[lua]local spawnTable = {}
local function spawn()
Ā Ā local localGroup = display.newGroup()
Ā Ā local layer1 = display.newRect( display.contentWidth*0.5, display.contentHeight*0.5, 100, 100 )
Ā Ā localGroup:insert(layer1)
Ā Ā local layer2 = display.newRect( display.contentWidth*0.5, display.contentHeight*0.5, 100, 100 )
Ā Ā localGroup:insert(layer2)
Ā Ā return localGroup
end
spawnTable[1] = spawn()
local function CheckButtonEvent( event )
Ā Ā if ( āendedā == event.phase ) then
Ā Ā local dude = {
Ā Ā Ā Ā type = āimageā,
Ā Ā Ā Ā filename = ādude5.pngā
Ā Ā }
Ā Ā local helmet = {
Ā Ā Ā Ā type = āimageā,
Ā Ā Ā Ā filename = āhelmet.pngā
Ā Ā }
Ā Ā spawnTable[1].layer1.fill = dude ā <-- How to fill group children?
Ā Ā spawnTable[1].layer2.fill = helmet ā <-- How to fill group children?
Ā Ā end
end
local checkbutton = widget.newButton
{
Ā Ā label = ācheckā,
Ā Ā id = ādingleberryā,
Ā Ā onEvent = CheckButtonEvent,
Ā Ā emboss = false,
Ā Ā shape=ācircleā,
Ā Ā radius = 20,
Ā Ā fillColor = { default={ 1, 1, 1}, over={ 1, 0.1, 0.7, 0.4 } },
Ā Ā strokeColor = { default={ 0, 0, 0, }, over={ 0.8, 0.8, 1, 1 } },
Ā Ā strokeWidth = 4
}
ā Place the jump button
checkbutton.x = display.contentWidth / 2
checkbutton.y = display.contentHeight / 2 +100[/lua]