feat(example): added sound system example

This commit is contained in:
lisk77 2025-11-27 00:16:41 +01:00
parent 4e2c18b0c1
commit 9777c4b6b4
2 changed files with 23 additions and 0 deletions

23
examples/hello_sound.rs Normal file
View file

@ -0,0 +1,23 @@
use comet::prelude::*;
fn setup(app: &mut App, _renderer: &mut Renderer2D) {
app.load_audio("startup", "res/sounds/hit.ogg");
app.play_audio("startup", true); // second parameter loops the sound
// here the float indicated the volume percentage
// in the standard backend for audio in comet (kira) 0.0 is equal to -20dB and 1.0 to 0dB
app.set_volume("startup", 1.0);
}
#[allow(unused_variables)]
fn update(app: &mut App, renderer: &mut Renderer2D, dt: f32) {
// in this example, update_audio doesnt do anything because the kira audio system
// doesnt need any update
app.update_audio(dt);
}
fn main() {
App::new()
.with_title("Comet Audio Example")
.run::<Renderer2D>(setup, update);
}