Removes all the sprites in a group from the animation.
The removed sprites won't be drawn or updated anymore.
// Left mouse button destroys yellow sprites, right mouse button destroys red sprites. var group1 = createGroup(); for (var i = 0; i < 5; i++) { group1.add(createSprite(randomNumber(0, 400), randomNumber(0, 400), 100, 100)); } group1.setColorEach("yellow"); var group2 = createGroup(); for (var i = 0; i < 5; i++) { group2.add(createSprite(randomNumber(0, 400), randomNumber(0, 400), 100, 100)); } group2.setColorEach("red"); function draw() { background("white"); drawSprites(); if (mouseDown("leftButton") ) { group1.destroyEach(); } if (mouseDown("rightButton") ) { group2.destroyEach(); } }
group.destroyEach()
No return value. Changes output in the display after drawSprites() is called.
Found a bug in the documentation? Let us know at documentation@code.org