mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-01 19:12:31 +08:00
* `ShapeComponent` changes size, position and angle of underlying Shape * Added description to ShapeComponent * Fix test * Update packages/flame/lib/src/components/shape_component.dart Co-authored-by: Erick <erickzanardoo@gmail.com> * Add absoluteScale and absoluteAngle to PositionComponent * Refactor ShapeComponent * Should be scaled by total scale, not scaled size * Premature optimization for creation for objects in Polygon * Use path for default Polygon constructor * Do not sync component and hitbox shape * Fix analyze issue * Add example for flipping with collision detection * Don't use absoluteScale * Fix examples * Fix examples * Doesn't need super.render * Fix Circle dartdoc * Update changelog * Update names of vertices caches in Polygon * Update text docs * Revert "Update text docs" This reverts commit 73a68a465d76eb0eb50bb3753e57b2f4e3b5a7f4. * Fix examples * ShapeComponents docs * Move example games to the top * Fix dartdoc comment about polygon vertex relation * Fix order of polygon vertices in dartdoc * Fix anchor for PolygonComponent.fromPoints * Add test with ancestors * Update doc/components.md Co-authored-by: Pasha Stetsenko <stpasha@google.com> * Update doc/components.md Co-authored-by: Erick <erickzanardoo@gmail.com> * Rename example classes * Fix linting issues in examples * Don't use px * Use isTrue and isFalse * Update doc/components.md Co-authored-by: Erick <erickzanardoo@gmail.com> * Fixed comments on PR Co-authored-by: Erick <erickzanardoo@gmail.com> Co-authored-by: Pasha Stetsenko <stpasha@google.com>
42 lines
975 B
Dart
42 lines
975 B
Dart
import 'package:flame/components.dart';
|
|
import 'package:flame/effects.dart';
|
|
import 'package:flame/extensions.dart';
|
|
import 'package:flame/game.dart';
|
|
import 'package:flame/input.dart';
|
|
|
|
import '../../commons/square_component.dart';
|
|
|
|
class MoveEffectGame extends FlameGame with TapDetector {
|
|
late SquareComponent square;
|
|
|
|
final List<Vector2> path = [
|
|
Vector2(100, 100),
|
|
Vector2(50, 120),
|
|
Vector2(200, 400),
|
|
Vector2(150, 150),
|
|
Vector2(100, 300),
|
|
];
|
|
|
|
@override
|
|
Future<void> onLoad() async {
|
|
await super.onLoad();
|
|
square = SquareComponent(size: 50, position: Vector2(200, 150));
|
|
add(square);
|
|
final pathMarkers =
|
|
path.map((p) => CircleComponent(radius: 3, position: p));
|
|
addAll(pathMarkers);
|
|
}
|
|
|
|
@override
|
|
void onTapUp(TapUpInfo info) {
|
|
square.add(
|
|
MoveEffect(
|
|
path: [info.eventPosition.game] + path,
|
|
speed: 250.0,
|
|
isAlternating: true,
|
|
peakDelay: 2.0,
|
|
),
|
|
);
|
|
}
|
|
}
|