Your First Flutter Flame Game

Mar 6 2024 · Dart 3, Flutter 3.10.1, Android Studio 2021.3.1 or higher, Visual Studo Code 1.7.4 or higher

Part 2: Effects & User Input

13. Play Sound Effects

Episode complete

Play next episode

Next
About this episode
Leave a rating/review
See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 12. Challenge: Add Movement to Saucer Next episode: 14. Understand Collision Between Components

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Notes: 13. Play Sound Effects

Here’s flame_audio’s documentation in case you need help.

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

Previously, you learned about sound effects.

Demo

Flame also simplifies the needed steps to add sound effects to your game.

pubspec.yaml

For now, just add flame_audio to the your pubspec.yaml. This package let’s you handle sound effects and you’ll be adding some soon.

flame_audio: ^2.0.5

MeteormaniaGame

Now, in MeteormaniaGame, you’ll have to load the different sound effects like you do with sprites.

await FlameAudio.audioCache.loadAll([
  'sfx/explosion.mp3',
  'sfx/laser.mp3',
  'sfx/destroy_meteorite.mp3',
]);
await FlameAudio.bgm.play('music/background_music.mp3', volume: 0.3);
FlameAudio.play('sfx/laser.mp3');