Пример #1
0
  public final boolean collidesWith(Sprite otherSprite) {

    if (otherSprite == null) {
      throw new NullPointerException();
    }

    // only check collision if both are visible
    if (!otherSprite.isVisible() || !this.isVisible()) return false;

    return collidesWith(otherSprite, 0, 0);
  }
Пример #2
0
  public Sprite(Sprite otherSprite) {
    // copy the otherSprite
    super(
        otherSprite.getX(),
        otherSprite.getY(),
        otherSprite.getWidth(),
        otherSprite.getHeight(),
        otherSprite.isVisible());
    this.frame = otherSprite.frame;
    this.sequence = otherSprite.sequence;
    this.cols = otherSprite.cols;
    this.rows = otherSprite.rows;
    this.transform = otherSprite.transform;
    this.img = otherSprite.img;

    this.collX = otherSprite.collX;
    this.collY = otherSprite.collY;
    this.collWidth = otherSprite.collWidth;
    this.collHeight = otherSprite.collHeight;
    tilesTextRegions = img.split((int) getWidth(), (int) getHeight());
  }