Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ;
- import flixel.FlxG;
- import flixel.math.FlxRandom;
- import motion.Actuate;
- import openfl.Assets;
- import openfl.events.Event;
- import openfl.media.Sound;
- import openfl.media.SoundChannel;
- import openfl.media.SoundTransform;
- /**
- * ...
- * @author MintPaw
- */
- class Sm
- {
- private static var _musicChannel:SoundChannel;
- private static var _musicVolume:Float = 1;
- public static var ORB:String = "music/orb";
- public static var DIE:String = "music/die";
- public static var SCREEN:String = "music/screen";
- public function new()
- {
- }
- public static function init():Void
- {
- FlxG.stage.addEventListener(Event.ENTER_FRAME, update);
- }
- public static function playMenuMusic():Void
- {
- if (_musicChannel != null) _musicChannel.stop();
- #if (mobile || desktop)
- var music:Sound = Assets.getSound("music/menu compressed.wav");
- #else
- var music:Sound = Assets.getSound("music/menu compressed.mp3");
- #end
- _musicChannel = music.play(0, 99999);
- _musicVolume = 0;
- Actuate.tween(Sm, 2, { _musicVolume: 1 } );
- }
- public static function menuToGameMusic():Void { Actuate.tween(Sm, 2, { _musicVolume: 0 } ).onComplete(Sm.playGameMusic, []); }
- public static function gameToMenuMusic():Void { Actuate.tween(Sm, 2, { _musicVolume: 0 } ).onComplete(Sm.playMenuMusic, []); }
- private static function update(e:Event):Void
- {
- if (_musicChannel == null) return;
- var t:SoundTransform = new SoundTransform();
- t.volume = _musicVolume;
- _musicChannel.soundTransform = t;
- }
- public static function playGameMusic():Void
- {
- if (_musicChannel != null) _musicChannel.stop();
- #if (mobile||desktop)
- var music:Sound = Assets.getSound("music/game compressed.wav");
- #else
- var music:Sound = Assets.getSound("music/game compressed.mp3");
- #end
- _musicChannel = music.play(0, 99999);
- _musicVolume = 0;
- Actuate.tween(Sm, 2, { _musicVolume: 1 } );
- }
- public static function playEffect(id:String):Void
- {
- #if (mobile||desktop)
- Assets.getSound(id + ".wav").play();
- #else
- Assets.getSound(id + ".mp3").play();
- #end
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement