API ReferenceGE Extensionsui
Credits Music
Plays credits background music via FMOD while the credits screen is active.
Plays credits background music via FMOD while the credits screen is active.
Overview
ui_credits is a minimal extension that creates an FMOD audio source for the credits music event, plays it on load, and cleans up on unload.
Extension path: lua/ge/extensions/ui/credits.lua
Exports (M)
| Function | Signature | Description |
|---|---|---|
onExtensionLoaded | () | Creates the credits music source and starts playback. |
onExtensionUnloaded | () | Stops and deletes the music source. |
Internals
Audio Setup
local function onExtensionLoaded()
soundParams = SFXParameterGroup("CreditsSoundParams")
creditsSoundId = Engine.Audio.createSource('AudioGui', 'event:>Music>credits')
local snd = scenetree.findObjectById(creditsSoundId)
if snd then
snd:play(-1) -- loop indefinitely
soundParams:addSource(snd.obj)
end
end- Audio group:
AudioGui - FMOD event:
event:>Music>credits - Parameter group:
CreditsSoundParams- allows external parameter control
Cleanup
local function onExtensionUnloaded()
if creditsSoundId then
Engine.Audio.deleteSource(creditsSoundId)
creditsSoundId = nil
end
endHow It Works
- Credits screen loads the extension via
extensions.load('ui_credits') onExtensionLoadedcreates and plays the credits music in a loop- When the credits screen closes,
extensions.unload('ui_credits')stops the music - The FMOD audio source is properly cleaned up to avoid leaks
Additional Exports
The following exports are available but not yet documented in detail:
M.onExtensionLoadedM.onExtensionUnloaded