forked from marco/firo_runner
#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:
parent
576730a06b
commit
80b40855fd
@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:firo_runner/main.dart';
|
import 'package:firo_runner/main.dart';
|
||||||
import 'package:flame/components.dart';
|
import 'package:flame/components.dart';
|
||||||
import 'package:flame/extensions.dart';
|
import 'package:flame/extensions.dart';
|
||||||
@ -11,9 +13,26 @@ class Firework extends Component {
|
|||||||
late SpriteAnimationGroupComponent sprite2;
|
late SpriteAnimationGroupComponent sprite2;
|
||||||
Firework(this.gameRef);
|
Firework(this.gameRef);
|
||||||
double timeSinceFirework = 0;
|
double timeSinceFirework = 0;
|
||||||
|
late Random random;
|
||||||
String message = "";
|
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 {
|
Future load() async {
|
||||||
|
random = Random();
|
||||||
Image firework = await Flame.images.load("fireworks-frames.png");
|
Image firework = await Flame.images.load("fireworks-frames.png");
|
||||||
|
|
||||||
SpriteAnimation normal = SpriteAnimation.fromFrameData(
|
SpriteAnimation normal = SpriteAnimation.fromFrameData(
|
||||||
@ -93,8 +112,7 @@ class Firework extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void reset() {
|
void reset() {
|
||||||
// message = gameRef.gameState.numCoins.toString();
|
message = messages.elementAt(random.nextInt(messages.length));
|
||||||
message = "Speed Up!";
|
|
||||||
sprite1.animation!.reset();
|
sprite1.animation!.reset();
|
||||||
sprite2.animation!.reset();
|
sprite2.animation!.reset();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user