Files
flame/examples/lib/stories/effects/move_effect.dart
Erick 6b2f8032fe Making Flame events aware of camera (#755)
* some initial refactoring

* Fixing examples and joystick component

* Fixing examples

* Addressing comments from PR

* Fixing tutorials

* Updating docs

* Fixing tests

* PR followup

* A big follow up

* linting

* doc nit

* Changelog and fix tutorial

* Addressing comments

* Fixing BaseGame project and scale offset methods

* Formatting

* doc suggestions

* Update packages/flame/lib/src/gestures/events.dart

Co-authored-by: Luan Nico <luanpotter27@gmail.com>

* Hopefully, the last follow up

* Linting and adding dart-code-metrics again

* fixing tutorial

Co-authored-by: Luan Nico <luanpotter27@gmail.com>
2021-04-15 15:28:46 -03:00

37 lines
853 B
Dart

import 'package:flame/effects.dart';
import 'package:flame/extensions.dart';
import 'package:flame/game.dart';
import 'package:flame/gestures.dart';
import 'package:flutter/material.dart';
import '../../commons/square_component.dart';
class MoveEffectGame extends BaseGame with TapDetector {
late SquareComponent square;
@override
Future<void> onLoad() async {
square = SquareComponent()..position.setValues(100, 100);
add(square);
}
@override
void onTapUp(TapUpInfo event) {
square.addEffect(
MoveEffect(
path: [
event.eventPosition.game,
Vector2(100, 100),
Vector2(50, 120),
Vector2(200, 400),
Vector2(150, 0),
Vector2(100, 300),
],
speed: 250.0,
curve: Curves.bounceInOut,
isAlternating: true,
),
);
}
}