Adding menu sounds
Next, we're going to handle playback of our whoosh, ting, and click sound effects. These will be used on both the title screen and the level-end screen.
Creating playback functions
To start, let's build the functions to play our sound effects. We'll start with the whoosh sound that will play when the star on the title screen and header on the level end screen tween in.
In SoundManager
, add this function:
public function playWhooshSound(delay:Float):Void { var timeout:Float = 1; FlxTween.num(timeout, 0, delay, { complete:function(tween:FlxTween) { FlxG.sound.play(Sounds.SOUND_WHOOSH,Sounds.VOLUME_WHOOSH); } }); }
This function takes in a float
value that will be used to delay playback of the sound effect. This will allow us to sync the sound effect up with the tweens on the title screen and level-end screen easier.
Inside the function we start by making a float
variable that we will tween down, named timeout
.
Next, we use a num
tween to delay the call to play...