Example #1
0
  @Override
  public void update(int delta) {
    if (!active) {
      return;
    }

    // calculate x
    x = entity.getX() - (Globals.APP_WIDTH / 2);
    if (x < 0) {
      x = 0;
    }
    if (x >= Engine.getMap().getWidth() - Globals.APP_WIDTH) {
      x = Engine.getMap().getWidth() - Globals.APP_WIDTH;
    }

    // calculate y
    y = entity.getY() - (Globals.APP_HEIGHT / 2);
    if (y < 0) {
      y = 0;
    }
    if (y >= Engine.getMap().getHeight() - Globals.APP_HEIGHT) {
      y = Engine.getMap().getHeight() - Globals.APP_HEIGHT;
    }

    // play the queued effect if there is one
    if (nextEffect != null) {
      if (!nextEffect.isFinished()) {
        nextEffect.update(delta);
      } else {
        nextEffect = null;
      }
    }
  }
Example #2
0
 /**
  * Creates a new {@link Camera}, following <code>entity</code>
  *
  * @param entity - the {@link AbstractEntity} to follow
  */
 public Camera(AbstractEntity entity) {
   this.entity = entity;
   Engine.setCamera(this);
 }