getTile method

Tile getTile()

Implementation

Tile getTile() {
  if (animation == null) {
    if (collisions?.isNotEmpty == true) {
      final tile = TileWithCollision.fromSprite(
        sprite: sprite?.getSprite(),
        position: Vector2(x, y),
        size: Vector2(width, height),
        offsetX: offsetX,
        offsetY: offsetY,
        collisions: collisions,
        type: type,
        properties: properties,
        color: color,
      );
      _setOtherParams(tile);
      return tile;
    } else {
      final tile = Tile.fromSprite(
        sprite: sprite?.getSprite(),
        position: Vector2(x, y),
        size: Vector2(width, height),
        offsetX: offsetX,
        offsetY: offsetY,
        type: type,
        properties: properties,
        color: color,
      );
      _setOtherParams(tile);

      return tile;
    }
  } else {
    if (collisions?.isNotEmpty == true) {
      ControlledUpdateAnimation animationControlled =
          animation!.getSpriteControlledAnimation();
      final tile = TileWithCollision.withAnimation(
        animation: animationControlled,
        position: Vector2(x, y),
        size: Vector2(width, height),
        offsetX: offsetX,
        offsetY: offsetY,
        collisions: collisions,
        type: type,
        properties: properties,
      );
      _setOtherParams(tile);

      return tile;
    } else {
      ControlledUpdateAnimation animationControlled =
          animation!.getSpriteControlledAnimation();
      final tile = Tile.fromAnimation(
        animation: animationControlled,
        position: Vector2(x, y),
        size: Vector2(width, height),
        offsetX: offsetX,
        offsetY: offsetY,
        type: type,
        properties: properties,
      );
      _setOtherParams(tile);

      return tile;
    }
  }
}