public void destroyAll(GroupLayer self) { AbstractLayer[] toDestroy = children.toArray(new AbstractLayer[children.size()]); // remove all of the children efficiently self.removeAll(); // now that the children have been detached, destroy them for (AbstractLayer child : toDestroy) { child.destroy(); } }
@Override public void init() { // remove the background layer added by default graphics().rootLayer().removeAll(); // add a grey square SurfaceImage surf = graphics().createSurface(width, height); surf.surface().setFillColor(Color.rgb(200, 200, 200)); surf.surface().fillRect(0, 0, width, height); square = graphics().createImageLayer(surf); graphics().rootLayer().add(square); }