From 66786ffb04bf3fe123660f0ce7a62f07beac46b4 Mon Sep 17 00:00:00 2001 From: ACrazyTown Date: Mon, 7 Oct 2024 14:40:08 +0200 Subject: [PATCH] add pitch to flxsound demo one more conditional... another one whoops Add pitch to FlxSound demo --- Features/FlxSound/assets/xml/menu.xml | 5 +++++ Features/FlxSound/source/MenuState.hx | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/Features/FlxSound/assets/xml/menu.xml b/Features/FlxSound/assets/xml/menu.xml index d36a881f4..9dd7fa401 100644 --- a/Features/FlxSound/assets/xml/menu.xml +++ b/Features/FlxSound/assets/xml/menu.xml @@ -41,7 +41,12 @@ + + + + + \ No newline at end of file diff --git a/Features/FlxSound/source/MenuState.hx b/Features/FlxSound/source/MenuState.hx index 23cd314f5..1277bbfb7 100644 --- a/Features/FlxSound/source/MenuState.hx +++ b/Features/FlxSound/source/MenuState.hx @@ -22,6 +22,9 @@ class MenuState extends FlxUIState { var loop_music:Bool = false; var music_volume:Float = 0.5; + #if !flash + var music_pitch:Float = 1.0; + #end var sfx_volume:Float = 0.5; var loop_count:Int = 0; @@ -38,6 +41,11 @@ class MenuState extends FlxUIState var butt_pause:FlxUIButton = cast _ui.getAsset("butt_pause"); enablePause(false); + + #if flash + _ui.removeAsset("music_pitch"); + _ui.removeAsset("music_pitch_label"); + #end } override public function getEvent(name:String, sender:Dynamic, data:Dynamic, ?params:Array):Void @@ -72,9 +80,18 @@ class MenuState extends FlxUIState { sfx_volume = nums.value; } + #if !flash + else if (wname == "music_pitch") + { + music_pitch = nums.value; + } + #end if (FlxG.sound.music != null && FlxG.sound.music.exists) { FlxG.sound.music.volume = music_volume; + #if !flash + FlxG.sound.music.pitch = music_pitch; + #end } for (sound in FlxG.sound.list.members) { @@ -124,6 +141,9 @@ class MenuState extends FlxUIState { fuib.toggled = true; FlxG.sound.playMusic(sound_id, music_volume, loop_music); + #if !flash + FlxG.sound.music.pitch = music_pitch; + #end FlxG.sound.music.onComplete = musicComplete; enablePause(true); }