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(
|
SpriteAnimation breaking = SpriteAnimation.fromFrameData(
|
||||||
breakingImage,
|
breakingImage,
|
||||||
SpriteAnimationData.sequenced(
|
SpriteAnimationData.sequenced(
|
||||||
amount: 12,
|
amount: 13,
|
||||||
stepTime: 0.01,
|
stepTime: 0.01,
|
||||||
textureSize: Vector2(512, 512),
|
textureSize: Vector2(512, 512),
|
||||||
loop: false,
|
loop: false,
|
||||||
|
@ -19,6 +19,7 @@ import 'package:flutter/services.dart';
|
|||||||
import 'Bug.dart';
|
import 'Bug.dart';
|
||||||
import 'Coin.dart';
|
import 'Coin.dart';
|
||||||
import 'Runner.dart';
|
import 'Runner.dart';
|
||||||
|
import 'package:flutter/foundation.dart' show kIsWeb;
|
||||||
|
|
||||||
const COLOR = const Color(0xFFDDC0A3);
|
const COLOR = const Color(0xFFDDC0A3);
|
||||||
|
|
||||||
@ -47,6 +48,7 @@ class MyGame extends BaseGame with PanDetector, TapDetector, KeyboardEvents {
|
|||||||
late WireHolder wireHolder;
|
late WireHolder wireHolder;
|
||||||
late BugHolder bugHolder;
|
late BugHolder bugHolder;
|
||||||
Random random = Random();
|
Random random = Random();
|
||||||
|
bool playingMusic = false;
|
||||||
|
|
||||||
late Runner runner;
|
late Runner runner;
|
||||||
late GameState gameState;
|
late GameState gameState;
|
||||||
@ -77,11 +79,18 @@ class MyGame extends BaseGame with PanDetector, TapDetector, KeyboardEvents {
|
|||||||
runner = Runner();
|
runner = Runner();
|
||||||
await runner.load(loadSpriteAnimation);
|
await runner.load(loadSpriteAnimation);
|
||||||
|
|
||||||
FlameAudio.bgm.play('Infinite_Spankage_M.mp3');
|
if (!kIsWeb) {
|
||||||
|
playMusic();
|
||||||
|
}
|
||||||
loaded = true;
|
loaded = true;
|
||||||
setUp();
|
setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void playMusic() {
|
||||||
|
FlameAudio.bgm.play('Infinite_Spankage_M.mp3');
|
||||||
|
playingMusic = true;
|
||||||
|
}
|
||||||
|
|
||||||
void fillScreen() {
|
void fillScreen() {
|
||||||
if (shouldReset) {
|
if (shouldReset) {
|
||||||
return;
|
return;
|
||||||
@ -236,6 +245,9 @@ class MyGame extends BaseGame with PanDetector, TapDetector, KeyboardEvents {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void onPanEnd(DragEndInfo info) {
|
void onPanEnd(DragEndInfo info) {
|
||||||
|
if (!playingMusic && kIsWeb) {
|
||||||
|
playMusic();
|
||||||
|
}
|
||||||
double xDelta = xDeltas.isEmpty
|
double xDelta = xDeltas.isEmpty
|
||||||
? 0
|
? 0
|
||||||
: xDeltas.reduce((value, element) => value + element);
|
: xDeltas.reduce((value, element) => value + element);
|
||||||
@ -259,6 +271,9 @@ class MyGame extends BaseGame with PanDetector, TapDetector, KeyboardEvents {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void onTap() {
|
void onTap() {
|
||||||
|
if (!playingMusic && kIsWeb) {
|
||||||
|
playMusic();
|
||||||
|
}
|
||||||
runner.control("center");
|
runner.control("center");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,6 +281,9 @@ class MyGame extends BaseGame with PanDetector, TapDetector, KeyboardEvents {
|
|||||||
var keyboardKey;
|
var keyboardKey;
|
||||||
@override
|
@override
|
||||||
void onKeyEvent(RawKeyEvent event) {
|
void onKeyEvent(RawKeyEvent event) {
|
||||||
|
if (!playingMusic && kIsWeb) {
|
||||||
|
playMusic();
|
||||||
|
}
|
||||||
if (event is RawKeyUpEvent) {
|
if (event is RawKeyUpEvent) {
|
||||||
keyboardKey = null;
|
keyboardKey = null;
|
||||||
switch (event.data.keyLabel) {
|
switch (event.data.keyLabel) {
|
||||||
|
Loading…
Reference in New Issue
Block a user