[client] added ogg sounds
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package ru.m.tankz;
|
||||
|
||||
import openfl.Assets;
|
||||
import ru.m.tankz.sound.SoundManager;
|
||||
import flash.events.KeyboardEvent;
|
||||
import flash.text.Font;
|
||||
@@ -91,6 +92,11 @@ class Client implements IConnectionHandler {
|
||||
Provider.setFactory(Game, ClassicGame, ClassicGame.TYPE);
|
||||
Provider.setFactory(Game, DotaGame, DotaGame.TYPE);
|
||||
|
||||
L.d(TAG, 'resources');
|
||||
for (resource in Assets.list()) {
|
||||
L.d(TAG, '\t${resource}');
|
||||
}
|
||||
|
||||
view.switcher.change(StartFrame.ID);
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ class GameFrame extends VGroupView implements ViewBuilder implements IPacketHand
|
||||
timer = new Timer(10);
|
||||
timer.run = updateEngine;
|
||||
state.text = stateString(game);
|
||||
Provider.get(SoundManager).play('start');
|
||||
}
|
||||
|
||||
private function stop():Void {
|
||||
|
||||
@@ -37,7 +37,13 @@ class StartFrame extends VGroupView implements ViewBuilder implements StartFrame
|
||||
}
|
||||
|
||||
public function onShow():Void {
|
||||
classic_load.visible = Provider.get(SaveStorage).read(ClassicGame.TYPE) != null;
|
||||
var save:GameSave = Provider.get(SaveStorage).read(ClassicGame.TYPE);
|
||||
if (save != null) {
|
||||
classic_load.visible = true;
|
||||
classic_load.text = 'Load (Level ${save.state.level})';
|
||||
} else {
|
||||
classic_load.visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
public function onPress(view:ButtonView):Void {
|
||||
|
||||
@@ -2,19 +2,29 @@ package ru.m.tankz.sound;
|
||||
|
||||
import ru.m.tankz.core.EntityType;
|
||||
import ru.m.tankz.engine.Engine;
|
||||
import flash.media.Sound;
|
||||
import openfl.media.Sound;
|
||||
import openfl.utils.Assets;
|
||||
|
||||
|
||||
class SoundManager implements EngineListener {
|
||||
private static var TAG(default, never):String = 'SoundManager';
|
||||
|
||||
#if flash
|
||||
private static var type:String = 'mp3';
|
||||
#else
|
||||
private static var type:String = 'ogg';
|
||||
#end
|
||||
|
||||
public function new() {}
|
||||
|
||||
public function play(id:String):Void {
|
||||
L.d(TAG, 'player: ${id}');
|
||||
var sound:Sound = Assets.getSound('resources/sounds/${id}.mp3');
|
||||
sound.play();
|
||||
L.d(TAG, 'play: ${id}');
|
||||
var sound:Sound = Assets.getSound('resources/sounds/${id}.${type}');
|
||||
if (sound != null) {
|
||||
sound.play();
|
||||
} else {
|
||||
L.w(TAG, 'Sound "${id}" not found');
|
||||
}
|
||||
}
|
||||
|
||||
public function onSpawn(entity:EntityType):Void {
|
||||
|
||||
Reference in New Issue
Block a user