我喜欢为在for循环中创建的层设置不同的层名。下面是正在工作的代码,但是它创建了三个名为“循环”的层,这阻止了我做任何特定的事情,比如第二个圆
for i in [1..3]
circle = new Layer
x: 15 + i*50
y: 15
height:10
width:10我试着做圆圈,但没成功。任何帮助都是非常感谢的。
发布于 2015-12-13 19:52:06
您需要创建层数组:
circles = []
for i in [1..3]
circles.push new Layer
x: 15 + i*50
y: 15
height: 10
width: 10或者更多的coffeescript‘’ish (thx @moo_is_too_short)
circles = for i in [1..3]
new Layer
x: 15 + i*50
y: 15
height: 10
width: 10和准入:
circles[0]
circles[1]
circles[2]https://stackoverflow.com/questions/34255340
复制相似问题