← Back to Docs
  • index.html
  • Clayground
  • Clayground.Sound
  • Sound
  • Clayground 2025.2
  • Sound QML Type

    Play sound effects with support for overlapping playback. More...

    Import Statement: import Clayground.Sound

    Properties

    Signals

    Methods

    Detailed Description

    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.

    Property Documentation

    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 [read-only]

    True when the sound data has been fully loaded and is ready to play.


    Signal Documentation

    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.


    Method Documentation

    void load()

    Explicitly load the sound data (useful with lazyLoading on WASM).