Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/flame/lib/src/effects/color_effect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,6 @@ class ColorEffect extends ComponentEffect<HasPaint> {
void reset() {
super.reset();
target.getPaint(paintId).colorFilter = _original;
target.onChanged();
}
}
26 changes: 26 additions & 0 deletions packages/flame/test/effects/color_effect_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,32 @@ void main() {
},
);

testWithFlameGame(
'reset notifies the component of the restored color filter',
(game) async {
final component = TextComponent<TextPaint>(text: 'foo');
await game.ensureAdd(component);

final effect = ColorEffect(
Colors.red,
EffectController(duration: 1),
);
await component.ensureAdd(effect);
game.update(0.5);
expect(
component.paintedTextRenderer.style.foreground!.colorFilter,
isNotNull,
);

effect.reset();

expect(
component.paintedTextRenderer.style.foreground!.colorFilter,
isNull,
);
},
);

testWithFlameGame(
'can be re-added in the component tree',
(game) async {
Expand Down
Loading