Teach Asteroids Sounds how to load from AssetBundle

@abarth
This commit is contained in:
Eric Seidel
2015-08-17 15:50:17 -07:00
parent 4cae568fec
commit 67c481b2ef
6 changed files with 24 additions and 17 deletions

View File

@@ -48,8 +48,8 @@ main() async {
_app = new GameDemoApp();
_sounds["explosion"] = new SoundEffect('https://github.com/slembcke/GalacticGuardian.spritebuilder/raw/GDC/Packages/SpriteBuilder%20Resources.sbpack/TempSounds/Explosion.wav');
_sounds["laser"] = new SoundEffect('https://github.com/slembcke/GalacticGuardian.spritebuilder/raw/GDC/Packages/SpriteBuilder%20Resources.sbpack/TempSounds/Laser.wav');
_sounds["explosion"] = new SoundEffect(_bundle.load('assets/explosion.wav'));
_sounds["laser"] = new SoundEffect(_bundle.load('assets/laser.wav'));
await _sounds["explosion"].load();
await _sounds["laser"].load();

View File

@@ -6,16 +6,15 @@ part of sprites;
typedef void SoundEffectStreamCallback(SoundEffectStream);
class SoundEffect {
SoundEffect(this._url);
SoundEffect(this._pipeFuture);
// TODO: Remove load method from SoundEffect
Future load() async {
UrlResponse response = await fetchUrl(_url);
_data = response.body;
_data = await _pipeFuture;
}
String _url;
Object _data;
Future<MojoDataPipeConsumer> _pipeFuture;
MojoDataPipeConsumer _data;
}
class SoundEffectStream {

View File

@@ -54,7 +54,6 @@ class SoundManager {
static void purgeSharedInstance() {
if (_sharedSoundManager == null) return;
_sharedSoundManager._running = false;
_sharedSoundManager = null;
}
@@ -72,7 +71,6 @@ class SoundManager {
bool enableBackgroundMusic;
bool enableSoundEffects;
bool _running = true;
int _lastTimeStamp;
void playEvent(SoundEvent evt, [double volume = 1.0, double pitch = 1.0, double pan = 0.0]) {

View File

@@ -10,6 +10,7 @@ import 'dart:math' as math;
import 'dart:typed_data';
import 'dart:sky';
import 'package:mojo/core.dart';
import 'package:mojo/mojo/url_response.mojom.dart';
import 'package:sky/animation/curves.dart';
import 'package:sky/base/scheduler.dart' as scheduler;