forked from flame-engine/flame
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Added rotate effect example and fixed multi-line (flame-engine#…
…2024) Added rotate effect and tested working. Effect resets.
- Loading branch information
1 parent
ccba5a1
commit 7b47ce1
Showing
4 changed files
with
94 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import 'package:doc_flame_examples/flower.dart'; | ||
import 'package:flame/effects.dart'; | ||
import 'package:flame/experimental.dart'; | ||
import 'package:flame/game.dart'; | ||
|
||
class RotateByEffectGame extends FlameGame with HasTappableComponents { | ||
bool reset = false; | ||
@override | ||
Future<void> onLoad() async { | ||
final flower = Flower( | ||
size: 60, | ||
position: canvasSize / 2, | ||
onTap: (flower) { | ||
if (reset = !reset) { | ||
flower.add( | ||
RotateEffect.by( | ||
tau / 4, | ||
EffectController(duration: 2), | ||
), | ||
); | ||
} else { | ||
flower.add( | ||
RotateEffect.by( | ||
-tau / 4, | ||
EffectController(duration: 2), | ||
), | ||
); | ||
} | ||
}, | ||
); | ||
add(flower); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import 'package:doc_flame_examples/flower.dart'; | ||
import 'package:flame/effects.dart'; | ||
import 'package:flame/experimental.dart'; | ||
import 'package:flame/game.dart'; | ||
|
||
class RotateToEffectGame extends FlameGame with HasTappableComponents { | ||
bool reset = false; | ||
@override | ||
Future<void> onLoad() async { | ||
final flower = Flower( | ||
size: 60, | ||
position: canvasSize / 2, | ||
onTap: (flower) { | ||
if (reset = !reset) { | ||
flower.add( | ||
RotateEffect.to( | ||
tau / 4, | ||
EffectController(duration: 2), | ||
), | ||
); | ||
} else { | ||
flower.add( | ||
RotateEffect.to( | ||
-tau / 4, | ||
EffectController(duration: 2), | ||
), | ||
); | ||
} | ||
}, | ||
); | ||
add(flower); | ||
} | ||
} |