docs: Fix examples for v1.9.0 (#2757)

Fixed up some examples that needed fixing before releasing v1.9.0
This commit is contained in:
Lukas Klingsbo
2023-09-21 21:24:40 +02:00
committed by GitHub
parent f5d0cb3856
commit 152fbb61db
14 changed files with 101 additions and 92 deletions

View File

@ -27,22 +27,21 @@ class _GestureHitboxesWorld extends World with TapCallbacks {
final shapeSize =
Vector2.all(100) + Vector2.all(50.0).scaled(_rng.nextDouble());
final shapeAngle = _rng.nextDouble() * 6;
final hitbox = () {
switch (shapeType) {
case Shapes.circle:
return CircleHitbox();
case Shapes.rectangle:
return RectangleHitbox();
case Shapes.polygon:
final points = [
-Vector2.random(_rng),
Vector2.random(_rng)..x *= -1,
Vector2.random(_rng),
Vector2.random(_rng)..y *= -1,
];
return PolygonHitbox.relative(points, parentSize: shapeSize);
}
}();
ShapeHitbox hitbox;
switch (shapeType) {
case Shapes.circle:
hitbox = CircleHitbox();
case Shapes.rectangle:
hitbox = RectangleHitbox();
case Shapes.polygon:
final points = [
-Vector2.random(_rng),
Vector2.random(_rng)..x *= -1,
Vector2.random(_rng),
Vector2.random(_rng)..y *= -1,
];
hitbox = PolygonHitbox.relative(points, parentSize: shapeSize);
}
return MyShapeComponent(
hitbox: hitbox,
position: position,