考虑 和 的两个Collection Grid
片段Layer with Click Animation
。下面只会给最后一个网格项(3:3位置的图层)添加一个动画监听器:
rows = 3
cols = 3
gutter = 16
width = 96
height = 96
for rowIndex in [0..rows-1]
for colIndex in [0..cols-1]
cellLayer = new Layer
width: width
height: height
x: colIndex * (width + gutter)
y: rowIndex * (height + gutter)
Utils.labelLayer cellLayer, "#{rowIndex}:#{colIndex}"
cellLayer.on Events.Click, ->
cellLayer.animate
properties:
scale: 1.4
curve: "spring"
如何在for
循环中单独命名图层以应用动画?
类似的东西cellLayer[rowIndex][colIndex] = new Layer
是理想的,但不起作用。