/** Sets specified sprite as the center of the background's viewport. */ public void setToCenter(Sprite centered) { this.setToCenter( (int) centered.getX(), (int) centered.getY(), centered.getWidth(), centered.getHeight()); }
/** * Returns the distance of this sprite from the specified sprite. * * <p>Used this method to check whether the specified sprite is in this sprite range area or not. * * <p>This method can be used for : * * <ul> * <li>Determining sprite attack range. * <li>Sprite aura that affecting surrounding unit. * <li>Activating this sprite to chase player whenever the player come closer to certain * distance of this sprite. * </ul> */ public double getDistance(Sprite other) { return Math.sqrt( Math.pow(this.getCenterX() - other.getCenterX(), 2) + Math.pow(this.getCenterY() - other.getCenterY(), 2)); }