Play sound effects with support for overlapping playback. More...
| Import Statement: | import Clayground.Sound |
Sound provides an easy-to-use interface for playing short sound effects like jump sounds, clicks, explosions, etc. Multiple instances of the same sound can play simultaneously (overlapping).
Example usage:
import Clayground.Sound
Sound {
id: jumpSound
source: "sounds/jump.wav"
volume: 0.8
}
// In game logic:
onJumped: jumpSound.play()
For background music with play/pause/stop/loop, use Music instead.
See also Music.
lazyLoading : bool |
When true, the sound is not loaded until load() or play() is called.
On desktop this is a no-op (files load instantly). Effective on WASM where network fetching is involved.
loaded : bool |
True when the sound data has been fully loaded and is ready to play.
errorOccurred(string message) |
Emitted when an error occurs during loading or playback.
Note: The corresponding handler is onErrorOccurred.
finished() |
Emitted when a sound effect finishes playing.
Note: The corresponding handler is onFinished.
void load() |
Explicitly load the sound data (useful with lazyLoading on WASM).