Skip to content Skip to sidebar Skip to footer

Removing Objects From A Layer Using Kineticjs

I am currently working a project involving KineticJS. I have to dynamically create and delete shapes constantly, but cannot seem to figure out how to do the latter. I've been tryi

Solution 1:

There are two functions that may be helpful.

  • childContainer.remove() removes the childContainer from it's parent.
  • parentContainer.removeChildren() removes all the children from this container.

Edit: This can also apply to shapes. Simply redraw the layer.

myShape.remove();
myLayer.draw();

Solution 2:

Somewhere between Kinetic 4.0 and the latest version, remove(child) stopped working. removeChild(child) doesn't work either.

I resolved this problem by using child.remove();

Solution 3:

U can use the prototype of kinetic function

Kinetic.Node.prototype.remove.call(removed_object);

baselayer.draw();

Post a Comment for "Removing Objects From A Layer Using Kineticjs"