fixed some minor bugs, and implemented fireworks fully.

This commit is contained in:
Marco Salazar 2021-09-10 13:25:01 -06:00
parent d56f87fef0
commit eb7491a852
4 changed files with 6 additions and 2 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 470 KiB

After

Width:  |  Height:  |  Size: 472 KiB

View File

@ -19,7 +19,7 @@ class Firework extends Component {
SpriteAnimation normal = SpriteAnimation.fromFrameData( SpriteAnimation normal = SpriteAnimation.fromFrameData(
firework, firework,
SpriteAnimationData.sequenced( SpriteAnimationData.sequenced(
amount: 9, amount: 10,
stepTime: 0.25, stepTime: 0.25,
textureSize: Vector2(512, 512), textureSize: Vector2(512, 512),
loop: false, loop: false,

View File

@ -170,7 +170,8 @@ class MyGame extends BaseGame with PanDetector, TapDetector, KeyboardEvents {
bool shouldReset = false; bool shouldReset = false;
void reset() { void reset() {
if (!(runner.sprite.animation?.done() ?? false)) { if (!(runner.sprite.animation?.done() ?? false) &&
runner.sprite.animation!.loop == false) {
return; return;
} }
runner.sprite.animation!.reset(); runner.sprite.animation!.reset();

View File

@ -218,6 +218,9 @@ class Runner extends Component with HasGameRef<MyGame> {
@override @override
void update(double dt) { void update(double dt) {
super.update(dt); super.update(dt);
if (sprite.position.y + sprite.size.y >= gameRef.size.y) {
event("die");
}
// If the animation is finished // If the animation is finished
if (sprite.animation?.done() ?? false) { if (sprite.animation?.done() ?? false) {
sprite.animation!.reset(); sprite.animation!.reset();