SoundFxBag-Component

The property of sound should be like this:

{
"muh": "assets/sounds/some_very_long_strange_name_with_cow.mp3",
"meh": "assets/sounds/some_very_long_strange_name_with_meh.mp3",
"multi": [
["mySound1.mp3", 1, 1, 0],
^ ^ ^
| | suspend
| pitch
gain
["mySound2.mp3", 1, 1, 0],
["mySound3.mp3", 1, [0.5, 2], 0], // random pitch between 0.5 and 2
]
}

If loaded successful one can do this:

const sounds = entity.findComponent("SoundFxBag"); sounds.playSimple('muh'); // simple sound const myHowlerSound = sounds.getSound('muh'); // full access

entity.sendMessage('PlaySfx', 'muh');
entity.sendMessage('PlaySfx', {name: 'muh', gain: 0.5} );

When sounds.playSimple('multi'); // is called both sounds are played at the given config

If a pending sound mix-entry exists during discard the mix-entry is still played using a setTimeout. This behavior can be undesired (e.g. causing effects being played in the next scene). For that the option discardSounds is for. Just put the discardSounds = {"multi": true} to make sure it does exceed lifetime of the object.

Set discardAll to true to make it a general options

Hierarchy

Constructors

Properties

entity: Entity = null
playLater: any[]
soundEnabled: boolean
sounds: any
requires: {
    children: ((props: any) => void);
    cmps: any[];
    props: {
        discardAll: (string | boolean)[];
        discardSounds: {}[];
        sounds: (string | boolean)[];
    };
    res: ((props: any) => string[]);
} = ...

Type declaration

  • children: ((props: any) => void)
      • (props: any): void
      • Parameters

        • props: any

        Returns void

  • cmps: any[]
  • props: {
        discardAll: (string | boolean)[];
        discardSounds: {}[];
        sounds: (string | boolean)[];
    }
    • discardAll: (string | boolean)[]
    • discardSounds: {}[]
    • sounds: (string | boolean)[]
  • res: ((props: any) => string[])
      • (props: any): string[]
      • Parameters

        • props: any

        Returns string[]

Accessors

Methods

Generated using TypeDoc