Skip to content

08 SFX

In this chapter, we will add SFX to Note.

Declaring

As before, declare the effect clip to be used:

TypeScript
export const effect = defineEffect({
    clips: {
        perfect: EffectClipName.Perfect,
    },
})
JavaScript
export const effect = defineEffect({
    clips: {
        perfect: EffectClipName.Perfect,
    },
})

Scheduling

Unlike play mode where we play SFX reactively when player taps the note, in watch mode we schedule SFX at the correct time so that Sonolus can sync up the audio perfectly:

TypeScript
export class Note extends Archetype {
    // ...

    preprocess() {
        // ...

        effect.clips.perfect.schedule(this.targetTime, 0.02)

        // ...
    }

    // ...
}
JavaScript
export class Note extends Archetype {
    // ...

    preprocess() {
        // ...

        effect.clips.perfect.schedule(this.targetTime, 0.02)

        // ...
    }

    // ...
}