Sequence Effect¶
This effect can be used to run multiple other effects one after another. The constituent effects may have different types.
The sequence effect can also be alternating (the sequence will first run forward, and then backward); and also repeat a certain predetermined number of times, or infinitely.
sequence_effect.dart
1import 'package:doc_flame_examples/flower.dart';
2import 'package:flame/effects.dart';
3import 'package:flame/game.dart';
4
5class SequenceEffectGame extends FlameGame {
6 @override
7 Future<void> onLoad() async {
8 final flower = Flower(
9 size: 40,
10 position: canvasSize / 2,
11 onTap: (flower) {
12 flower.add(
13 SequenceEffect([
14 ScaleEffect.by(
15 Vector2.all(1.5),
16 EffectController(duration: 0.2, alternate: true),
17 ),
18 MoveEffect.by(
19 Vector2(30, -50),
20 EffectController(duration: 0.5),
21 ),
22 MoveEffect.by(
23 Vector2(-30, 50),
24 EffectController(duration: 0.5),
25 ),
26 ScaleEffect.by(
27 Vector2.all(0.75),
28 EffectController(duration: 0.2, alternate: true),
29 ),
30 ]),
31 );
32 },
33 );
34 add(flower);
35 }
36}
final effect = SequenceEffect([
ScaleEffect.by(
Vector2.all(1.5),
EffectController(
duration: 0.2,
alternate: true,
),
),
MoveEffect.by(
Vector2(30, -50),
EffectController(
duration: 0.5,
),
),
OpacityEffect.to(
0,
EffectController(
duration: 0.3,
),
),
RemoveEffect(),
]);
The content on this page is licensed under the CC BY 4.0 License,
and code samples under the MIT License.