Why don't these circles have different colors?
Why does:
local circle = {}
for i = 1, 15 do
开发者_Python百科 for j = 1, 15 do
circle[i] = display.newCircle( 0 + (i*20), 100 + (j*20), 9)
circle[i]:setFillColor(128, 128, i)
end
end
not produce 255 circles with different colours? (if it is setting them all individually)
How could it produce 255 circles?
i
only goes from 1 to 15. Therefore, circle
will only contain 16 entries. I think what you're looking for is something more like this:
local circle = {}
for i = 1, 15 do
for j = 1, 15 do
circle[#circle + 1] = display.newCircle( 0 + (i*20), 100 + (j*20), 9)
circle[#circle]:setFillColor(128, 128, (i * 16) + j)
end
end
精彩评论