Skip to content

Commit

Permalink
feat: Adding key argument to shape components (#2632)
Browse files Browse the repository at this point in the history
Components based on `ShapeComponent` were missing the `key` constructor
argument. This PR addresses that.
  • Loading branch information
erickzanardo authored Aug 2, 2023
1 parent dac2ebb commit c542d3c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/flame/lib/src/geometry/polygon_component.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class PolygonComponent extends ShapeComponent {
super.priority,
super.paint,
super.paintLayers,
super.key,
bool? shrinkToBounds,
}) : assert(
_vertices.length > 2,
Expand Down Expand Up @@ -78,6 +79,7 @@ class PolygonComponent extends ShapeComponent {
Paint? paint,
List<Paint>? paintLayers,
bool? shrinkToBounds,
ComponentKey? key,
}) : this(
normalsToVertices(relation, parentSize),
position: position,
Expand All @@ -88,6 +90,7 @@ class PolygonComponent extends ShapeComponent {
paint: paint,
paintLayers: paintLayers,
shrinkToBounds: shrinkToBounds,
key: key,
);

@internal
Expand Down
5 changes: 5 additions & 0 deletions packages/flame/lib/src/geometry/rectangle_component.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class RectangleComponent extends PolygonComponent {
super.priority,
super.paint,
super.paintLayers,
super.key,
}) : super(sizeToVertices(size ?? Vector2.zero(), anchor)) {
size.addListener(
() => refreshVertices(
Expand All @@ -32,6 +33,7 @@ class RectangleComponent extends PolygonComponent {
super.paint,
super.paintLayers,
super.children,
super.key,
}) : super(sizeToVertices(Vector2.all(size), anchor)) {
this.size.addListener(
() => refreshVertices(
Expand All @@ -56,6 +58,7 @@ class RectangleComponent extends PolygonComponent {
super.paint,
super.paintLayers,
super.shrinkToBounds,
super.key,
}) : super.relative([
relation.clone(),
Vector2(relation.x, -relation.y),
Expand All @@ -78,6 +81,7 @@ class RectangleComponent extends PolygonComponent {
int? priority,
Paint? paint,
List<Paint>? paintLayers,
ComponentKey? key,
}) {
return RectangleComponent(
position: anchor == Anchor.topLeft
Expand All @@ -93,6 +97,7 @@ class RectangleComponent extends PolygonComponent {
priority: priority,
paint: paint,
paintLayers: paintLayers,
key: key,
);
}

Expand Down
1 change: 1 addition & 0 deletions packages/flame/lib/src/geometry/shape_component.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ abstract class ShapeComponent extends PositionComponent with HasPaint {
super.anchor,
super.children,
super.priority,
super.key,
Paint? paint,
List<Paint>? paintLayers,
}) {
Expand Down

0 comments on commit c542d3c

Please sign in to comment.