开发者

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜