我正在使用 for() 语句创建矩形节点,现在我需要获取每个节点的引用。似乎有一些黑魔法来创建这些画布对象,因此很难访问没有 id 可引用的项目。有人可以解决这个问题或指出我正确的方向吗?
for(x=1;x<=8;x++)
{
var rect = new Kinetic.Rect({
x: 300,
y: 80+offset,
width: 60,
height: 20,
fill: 'white',
stroke: 'black',
strokeWidth: 1,
draggable: false
});
rect.on('mouseover', function() {
writeMessage(messageLayer, this.getY());
});
// add the shape to the layer
layer.add(rect);
offset += 120;
谢谢