#9, made it ready to display messages at different speed levels. Just needs to be adjusted according to what is desired.

This commit is contained in:
Marco Salazar 2021-09-18 19:07:27 -06:00
parent 576730a06b
commit 80b40855fd

View File

@ -1,3 +1,5 @@
import 'dart:math';
import 'package:firo_runner/main.dart';
import 'package:flame/components.dart';
import 'package:flame/extensions.dart';
@ -11,9 +13,26 @@ class Firework extends Component {
late SpriteAnimationGroupComponent sprite2;
Firework(this.gameRef);
double timeSinceFirework = 0;
late Random random;
String message = "";
List<String> messages = [
"Speed Up!",
"Speed Up!",
"Speed Up!",
"Speed Up!",
"Speed Up!",
"Speed Up!",
"Speed Up!",
"Speed Up!",
"Speed Up!",
"Speed Up!",
"Speed Up!",
"Speed Up!",
"Speed Up!",
];
Future load() async {
random = Random();
Image firework = await Flame.images.load("fireworks-frames.png");
SpriteAnimation normal = SpriteAnimation.fromFrameData(
@ -93,8 +112,7 @@ class Firework extends Component {
}
void reset() {
// message = gameRef.gameState.numCoins.toString();
message = "Speed Up!";
message = messages.elementAt(random.nextInt(messages.length));
sprite1.animation!.reset();
sprite2.animation!.reset();
}