开发者

Why don't these circles have different colors?

开发者 https://www.devze.com 2023-04-02 01:34 出处:网络
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)

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

精彩评论

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