Skip to content

Trigger API Reference DCEI Functions Sound0

BlackTower edited this page Aug 2, 2022 · 11 revisions
Table of Contents
- [Trigger API Reference\DCEI Functions\Sound](#trigger-api-referencedcei-functionssound) * [bool IsMusicEnabled()](#bool-ismusicenabled) * [bool IsSoundEnabled()](#bool-issoundenabled) * [void PlayMusic(string name, bool smoothTransition)](#void-playmusicstring-name-bool-smoothtransition) * [void SetMusicVolume(float volume)](#void-setmusicvolumefloat-volume) * [void PauseMusic()](#void-pausemusic) * [void ResumeMusic()](#void-resumemusic) * [void PlaySound(string nameOrPath, float volume)](#void-playsoundstring-nameorpath-float-volume) * [void PlaySoundForPlayer(string nameOrPath, int playerId, float volume)](#void-playsoundforplayerstring-nameorpath-int-playerid-float-volume)

Trigger API Reference\DCEI Functions\Sound {Trigger-API-ReferenceDCEI-FunctionsSound}

bool IsMusicEnabled() {bool-IsMusicEnabled}

bool IsMusicEnabled()

Description

Returns if the music is enabled or not.

Example Usage

bool IsSoundEnabled() {bool-IsSoundEnabled}

bool IsSoundEnabled()

Description

Returns if the sound is enabled.

Example Usage

void PlayMusic(string name, bool smoothTransition) {void-PlayMusicstring-name-bool-smoothTransition}

void PlayMusic(string name, bool smoothTransition)

Description

Plays the specified song on repeat. This will replace the default music played. Music must be declared in Music Settings.

Parameters

  • string name the name of the music asset to play. Accepted music names:

    Battle1
    Battle2
    Battle3
    Hometown1
    Boss1
    
  • bool smoothTransition if we want a smooth transition from current music to this one

Example Usage

DCEI.PlayMusic("Boss1", true)

void SetMusicVolume(float volume) {void-SetMusicVolumefloat-volume}

void SetMusicVolume(float volume)

Description

Sets the music volume.

Parameters

  • float volume the new music volume.

Example Usage

DCEI.SetMusicVolume(0.5)

void PauseMusic() {void-PauseMusic}

void PauseMusic()

Description

Pauses the music currently playing. Cannot be used on the game's first frame as the music hasn't initialized yet.

Example Usage

function OnClickRMB()
    DCEI.PauseMusic()
end

DCEI.TriggerAddMouseDownEvent(1, OnClickRMB)

void ResumeMusic() {void-ResumeMusic}

void ResumeMusic()

Description

Resumes paused music. If music is currently not paused, restarts the music currently playing.

Example Usage

function OnClickLMB()
    DCEI.ResumeMusic()
end

DCEI.TriggerAddMouseDownEvent(0, OnClickLMB)

void PlaySound(string nameOrPath, float volume) {void-PlaySoundstring-nameOrPath-float-volume}

void PlaySound(string nameOrPath, float volume)

Description

Plays the given sound at the given volume. A given volume of 0 will playback at the default volume. While volume doesn't have an explicit maximum value, it's recommended to keep this under 5.

Parameters

  • string nameOrPath the name of the sound or path to the sound.
  • float volume the playback volume for the sound.

Example Usage

DCEI.PlaySound("ancienttree_ability_01", 0.5)

void PlaySoundForPlayer(string nameOrPath, int playerId, float volume) {void-PlaySoundForPlayerstring-nameOrPath-int-playerId-float-volume}

void PlaySoundForPlayer(string nameOrPath, int playerId, float volume)

Description

Play sound for a specific player. Only useful in multiplayer.

Parameters

Example Usage

Clone this wiki locally