From 4039a577d1bbbae714de3cf4e4b7198ebcc0c2d5 Mon Sep 17 00:00:00 2001 From: RuiAlonso Date: Tue, 26 Apr 2022 20:22:04 +0200 Subject: [PATCH] feat: positioned multiball and changed animation --- .../lib/src/components/multiball.dart | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/packages/pinball_components/lib/src/components/multiball.dart b/packages/pinball_components/lib/src/components/multiball.dart index 52fe8bd5..a0741cf7 100644 --- a/packages/pinball_components/lib/src/components/multiball.dart +++ b/packages/pinball_components/lib/src/components/multiball.dart @@ -1,3 +1,4 @@ +import 'dart:math' as math; import 'package:flame/components.dart'; import 'package:flutter/material.dart'; import 'package:pinball_components/gen/assets.gen.dart'; @@ -25,45 +26,49 @@ class Multiball extends Component { /// {@macro multiball} Multiball.a() : this._( - position: Vector2(0, 0), + position: Vector2(-23, 7.5), onAssetPath: Assets.images.multiball.a.active.keyName, offAssetPath: Assets.images.multiball.a.inactive.keyName, - rotation: 0, + rotation: -24 * math.pi / 180, ); /// {@macro multiball} Multiball.b() : this._( - position: Vector2(0, 0), + position: Vector2(-7, -6.5), onAssetPath: Assets.images.multiball.b.active.keyName, offAssetPath: Assets.images.multiball.b.inactive.keyName, - rotation: 0, + rotation: -5 * math.pi / 180, ); /// {@macro multiball} Multiball.c() : this._( - position: Vector2(0, 0), + position: Vector2(-0.5, -9.5), onAssetPath: Assets.images.multiball.c.active.keyName, offAssetPath: Assets.images.multiball.c.inactive.keyName, - rotation: 0, + rotation: 3 * math.pi / 180, ); /// {@macro multiball} Multiball.d() : this._( - position: Vector2(0, 0), + position: Vector2(15, 7), onAssetPath: Assets.images.multiball.d.active.keyName, offAssetPath: Assets.images.multiball.d.inactive.keyName, - rotation: 0, + rotation: 24 * math.pi / 180, ); /// Animates the [Multiball]. Future animate() async { - final spriteGroupComponent = firstChild() - ?..current = MultiballSpriteState.active; - await Future.delayed(const Duration(milliseconds: 50)); - spriteGroupComponent?.current = MultiballSpriteState.inactive; + final spriteGroupComponent = firstChild(); + + for (var i = 0; i < 5; i++) { + spriteGroupComponent?.current = MultiballSpriteState.active; + await Future.delayed(const Duration(milliseconds: 100)); + spriteGroupComponent?.current = MultiballSpriteState.inactive; + await Future.delayed(const Duration(milliseconds: 100)); + } } }