Step 15 - Flappy Sounds and Music
Finally to really add depth to a game let's add some sound! ex.Sound needs to be loaded much like ex.ImageSource.
Excalibur supports any audio your browser supports, you can specify an ordered list of files to fallback to if a browser doesn't support.
typescript// resources.tsexport const Resources = {// Relative to /public in vite...// SoundsFlapSound: new ex.Sound('./sounds/flap.wav'),FailSound: new ex.Sound('./sounds/fail.wav'),ScoreSound: new ex.Sound('./sounds/score.wav'),// MusicBackgroundMusic: new ex.Sound('./sounds/two_left_socks.ogg')} as const;
typescript// resources.tsexport const Resources = {// Relative to /public in vite...// SoundsFlapSound: new ex.Sound('./sounds/flap.wav'),FailSound: new ex.Sound('./sounds/fail.wav'),ScoreSound: new ex.Sound('./sounds/score.wav'),// MusicBackgroundMusic: new ex.Sound('./sounds/two_left_socks.ogg')} as const;