mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-03 20:36:31 +08:00
* Animations, CameraAndViewport, CollisionDetection and Components unified * Added descriptions to effects * Rename input games * Unify input stories * Add info to parallax section * Added descriptions to the rendering examples * Add descriptions to the sprites directory * Fix utils and rendering section * Add descriptions to the widgets section * Delete directory that rebase brought back * Unify game names * Added some styleguide docs for examples * Fix analyze issues * All files should have _example as suffix * Made the FollowComponentExample a bit easier to understand * Change priority of ember
49 lines
1.3 KiB
Dart
49 lines
1.3 KiB
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 OldMoveEffectExample extends FlameGame with TapDetector {
|
|
static const String description = '''
|
|
This example showcases the `MoveEffect`. Click somewhere on the screen and
|
|
the white square will go there and then it will follow the path that is
|
|
laid out by the white circular markers. After it has finished the path it
|
|
waits for a bit and then returns to its original position.
|
|
''';
|
|
|
|
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,
|
|
),
|
|
);
|
|
}
|
|
}
|