从组中删除节点(对象,组等)

时间:2013-10-30 15:35:12

标签: javascript kineticjs

我想创建临时组并向其添加节点,以便它们变得可拖动(因为组是)。 然后我想从该组中删除那些节点并将其他节点添加到该组,使它们可移动而其他节点不可移动。

Group is movableGroup:

var movableGroup= new Kinetic.Group({
    draggable: true,
});

我想为它添加形状。

我想为它添加新形状并删除在这些形状之前添加的形状。

1 个答案:

答案 0 :(得分:1)

删除组中的所有子节点:

moveableGroup.removeChildren();

然后您可以向该组添加一些新节点:

var box = new Kinetic.Rect({
    x: 0,
    y: 0,
    width: width,
    height: height,
    stroke : 'black',
    strokeWidth: 1
});

moveableGroup.add(box);