public void update(float delta) { if (MathUtils.random() < delta * Constants.ICICLE_SPAWNS_PER_SECOND) { Vector2 newIciclePosition = new Vector2(MathUtils.random() * viewport.getWorldWidth(), viewport.getWorldHeight()); Icicle newIcicle = new Icicle(newIciclePosition); icicleList.add(newIcicle); } for (Icicle icicle : icicleList) { icicle.update(delta); } // TODO: begin a removal session icicleList.begin(); // TODO: Remove any icicle completely off the bottom of the screen for (int i = 0; i < icicleList.size; i++) { if (icicleList.get(i).position.y < -Constants.ICICLES_HEIGHT) { icicleList.removeIndex(i); } } // TODO: End removal session icicleList.end(); }
public boolean addListener(EventListener listener) { if (!listeners.contains(listener, true)) { listeners.add(listener); return true; } return false; }
/** * Adds an actor as a child of this group. The actor is first removed from its parent group, if * any. */ public void addActor(Actor actor) { actor.remove(); children.add(actor); actor.setParent(this); actor.setStage(getStage()); childrenChanged(); }
/** * Adds an actor as a child of this group, immediately after another child actor. The actor is * first removed from its parent group, if any. */ public void addActorAfter(Actor actorAfter, Actor actor) { actor.remove(); int index = children.indexOf(actorAfter, true); if (index == children.size) children.add(actor); else children.insert(index + 1, actor); actor.setParent(this); actor.setStage(getStage()); childrenChanged(); }
public void update(float delta) { if (MathUtils.random() < delta * Constants.ICICLE_SPAWNS_PER_SECOND) { Vector2 newIciclePosition = new Vector2(MathUtils.random() * viewport.getWorldWidth(), viewport.getWorldHeight()); Icicle newIcicle = new Icicle(newIciclePosition); icicleList.add(newIcicle); } for (Icicle icicle : icicleList) { icicle.update(delta); } icicleList.begin(); for (int i = 0; i < icicleList.size; i++) { if (icicleList.get(i).position.y < -Constants.ICICLES_HEIGHT) { // TODO: Increment count of icicles dodged iciclesDodged++; icicleList.removeIndex(i); } } icicleList.end(); }
/** * Adds a listener that is only notified during the capture phase. * * @see #fire(Event) */ public boolean addCaptureListener(EventListener listener) { if (!captureListeners.contains(listener, true)) captureListeners.add(listener); return true; }