Hi,
I’m a complete newby here. I’m trying to self teach myself how to use Lua and corona so forgive me if I’m completely off here.
I’m trying to create a loop which displays 10 circles across the screen, which I have managed to do here:
local x = 10 local field = display.newGroup() local houseButtons = {} for i = 1, 10 do houseButtons = display.newCircle(75 + x, 100, 15, 15) houseButtons.id = i field:insert(houseButtons) local text = display.newText(i, 75 + x, 100, native.systemFontBold, 12 ) text:setFillColor( 1, 0, 0 ) x = x + 35 field:insert(text) houseButtons:addEventListener( "tap", touchMe ) end
I wanted to be able to colour the indivual circles, which I thought I could do with:
houseButtons[5].fill = { 0.32, 0.5, 0.2 }
but no, that doesn’t work. I was able to colour one by using:
if houseButtons.id == 3 then
houseButtons.fill = { 0.32, 0.5, 0.2 }
end
but that doesn’t seem like the best practice. What I would really like to be able to do is look up a variable number and colour the circles up to that number.
Would anyone be point me in the correct direction please
thanks