getTile method
Implementation
Tile getTile(BonfireGameInterface gameRef) {
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,
);
tile.angle = angle;
tile.isFlipHorizontal = isFlipHorizontal;
tile.isFlipVertical = isFlipVertical;
tile.gameRef = gameRef;
tile.id = id;
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,
);
tile.angle = angle;
tile.isFlipHorizontal = isFlipHorizontal;
tile.isFlipVertical = isFlipVertical;
tile.gameRef = gameRef;
tile.id = id;
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,
);
tile.angle = angle;
tile.isFlipHorizontal = isFlipHorizontal;
tile.isFlipVertical = isFlipVertical;
tile.gameRef = gameRef;
tile.id = id;
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,
);
tile.angle = angle;
tile.isFlipHorizontal = isFlipHorizontal;
tile.isFlipVertical = isFlipVertical;
tile.gameRef = gameRef;
tile.id = id;
return tile;
}
}
}