コード例 #1
0
  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();
  }
コード例 #2
0
ファイル: Actor.java プロジェクト: newisso/libgdx
 public boolean addListener(EventListener listener) {
   if (!listeners.contains(listener, true)) {
     listeners.add(listener);
     return true;
   }
   return false;
 }
コード例 #3
0
ファイル: Group.java プロジェクト: btdiehr/libgdx
 /**
  * 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();
 }
コード例 #4
0
ファイル: Group.java プロジェクト: btdiehr/libgdx
 /**
  * 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();
 }
コード例 #5
0
  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();
  }
コード例 #6
0
ファイル: Actor.java プロジェクト: newisso/libgdx
 /**
  * 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;
 }