|
|
|
@ -1,7 +1,6 @@
|
|
|
|
|
// ignore_for_file: public_member_api_docs
|
|
|
|
|
|
|
|
|
|
import 'package:flame/flame.dart';
|
|
|
|
|
import 'package:flame/image_composition.dart';
|
|
|
|
|
import 'package:flame/sprite.dart';
|
|
|
|
|
import 'package:flame/widgets.dart';
|
|
|
|
|
import 'package:flutter/material.dart' hide Image;
|
|
|
|
@ -45,46 +44,43 @@ class BonusAnimation extends StatelessWidget {
|
|
|
|
|
|
|
|
|
|
final VoidCallback? onCompleted;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
static Future<void> loadAssets() {
|
|
|
|
|
Flame.images.prefix = '';
|
|
|
|
|
return Flame.images.loadAll([
|
|
|
|
|
Assets.images.bonusAnimation.dashNest.keyName,
|
|
|
|
|
Assets.images.bonusAnimation.sparkyTurboCharge.keyName,
|
|
|
|
|
Assets.images.bonusAnimation.dino.keyName,
|
|
|
|
|
// TODO: add google word animation asset here
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO(arturplaczek): Load assets in parent widget, remove future builder
|
|
|
|
|
// and user image from cache.
|
|
|
|
|
return FutureBuilder<Image>(
|
|
|
|
|
future: Flame.images.load(imagePath),
|
|
|
|
|
builder: (BuildContext context, AsyncSnapshot<Image> snapshot) {
|
|
|
|
|
if (snapshot.hasData) {
|
|
|
|
|
final spriteSheet = SpriteSheet.fromColumnsAndRows(
|
|
|
|
|
image: snapshot.data!,
|
|
|
|
|
columns: 8,
|
|
|
|
|
rows: 9,
|
|
|
|
|
);
|
|
|
|
|
final animation = spriteSheet.createAnimation(
|
|
|
|
|
row: 0,
|
|
|
|
|
stepTime: 1 / 24,
|
|
|
|
|
to: spriteSheet.rows * spriteSheet.columns,
|
|
|
|
|
loop: false,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
Future<void>.delayed(
|
|
|
|
|
Duration(seconds: animation.totalDuration().ceil()),
|
|
|
|
|
() {
|
|
|
|
|
onCompleted?.call();
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return SizedBox(
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
height: double.infinity,
|
|
|
|
|
child: SpriteAnimationWidget(
|
|
|
|
|
animation: animation,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
final spriteSheet = SpriteSheet.fromColumnsAndRows(
|
|
|
|
|
image: Flame.images.fromCache(imagePath),
|
|
|
|
|
columns: 8,
|
|
|
|
|
rows: 9,
|
|
|
|
|
);
|
|
|
|
|
final animation = spriteSheet.createAnimation(
|
|
|
|
|
row: 0,
|
|
|
|
|
stepTime: 1 / 24,
|
|
|
|
|
to: spriteSheet.rows * spriteSheet.columns,
|
|
|
|
|
loop: false,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return const SizedBox();
|
|
|
|
|
Future<void>.delayed(
|
|
|
|
|
Duration(seconds: animation.totalDuration().ceil()),
|
|
|
|
|
() {
|
|
|
|
|
onCompleted?.call();
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return SizedBox(
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
height: double.infinity,
|
|
|
|
|
child: SpriteAnimationWidget(
|
|
|
|
|
animation: animation,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|