forked from marco/firo_runner
Added some new image assets, and fixed the bug so that audio plays on web.
This commit is contained in:
parent
7736eb1a1b
commit
7fa49eb824
Binary file not shown.
Before Width: | Height: | Size: 516 KiB After Width: | Height: | Size: 881 KiB |
Binary file not shown.
Before Width: | Height: | Size: 249 KiB After Width: | Height: | Size: 280 KiB |
@ -20,7 +20,7 @@ class Bug extends MovingObject {
|
||||
SpriteAnimation breaking = SpriteAnimation.fromFrameData(
|
||||
breakingImage,
|
||||
SpriteAnimationData.sequenced(
|
||||
amount: 12,
|
||||
amount: 13,
|
||||
stepTime: 0.01,
|
||||
textureSize: Vector2(512, 512),
|
||||
loop: false,
|
||||
|
@ -19,6 +19,7 @@ import 'package:flutter/services.dart';
|
||||
import 'Bug.dart';
|
||||
import 'Coin.dart';
|
||||
import 'Runner.dart';
|
||||
import 'package:flutter/foundation.dart' show kIsWeb;
|
||||
|
||||
const COLOR = const Color(0xFFDDC0A3);
|
||||
|
||||
@ -47,6 +48,7 @@ class MyGame extends BaseGame with PanDetector, TapDetector, KeyboardEvents {
|
||||
late WireHolder wireHolder;
|
||||
late BugHolder bugHolder;
|
||||
Random random = Random();
|
||||
bool playingMusic = false;
|
||||
|
||||
late Runner runner;
|
||||
late GameState gameState;
|
||||
@ -77,11 +79,18 @@ class MyGame extends BaseGame with PanDetector, TapDetector, KeyboardEvents {
|
||||
runner = Runner();
|
||||
await runner.load(loadSpriteAnimation);
|
||||
|
||||
FlameAudio.bgm.play('Infinite_Spankage_M.mp3');
|
||||
if (!kIsWeb) {
|
||||
playMusic();
|
||||
}
|
||||
loaded = true;
|
||||
setUp();
|
||||
}
|
||||
|
||||
void playMusic() {
|
||||
FlameAudio.bgm.play('Infinite_Spankage_M.mp3');
|
||||
playingMusic = true;
|
||||
}
|
||||
|
||||
void fillScreen() {
|
||||
if (shouldReset) {
|
||||
return;
|
||||
@ -236,6 +245,9 @@ class MyGame extends BaseGame with PanDetector, TapDetector, KeyboardEvents {
|
||||
|
||||
@override
|
||||
void onPanEnd(DragEndInfo info) {
|
||||
if (!playingMusic && kIsWeb) {
|
||||
playMusic();
|
||||
}
|
||||
double xDelta = xDeltas.isEmpty
|
||||
? 0
|
||||
: xDeltas.reduce((value, element) => value + element);
|
||||
@ -259,6 +271,9 @@ class MyGame extends BaseGame with PanDetector, TapDetector, KeyboardEvents {
|
||||
|
||||
@override
|
||||
void onTap() {
|
||||
if (!playingMusic && kIsWeb) {
|
||||
playMusic();
|
||||
}
|
||||
runner.control("center");
|
||||
}
|
||||
|
||||
@ -266,6 +281,9 @@ class MyGame extends BaseGame with PanDetector, TapDetector, KeyboardEvents {
|
||||
var keyboardKey;
|
||||
@override
|
||||
void onKeyEvent(RawKeyEvent event) {
|
||||
if (!playingMusic && kIsWeb) {
|
||||
playMusic();
|
||||
}
|
||||
if (event is RawKeyUpEvent) {
|
||||
keyboardKey = null;
|
||||
switch (event.data.keyLabel) {
|
||||
|
Loading…
Reference in New Issue
Block a user