Hi all,
I’ve just been reading (again) through all the tutorials on requiring modules and I have 1 simple question if anyone can clear up for me would be a great help.
I will give just one example of a module I use in every scene, sfx.lua
I load all my sounds in this module
sfx.lua
local sfx = {}
sfx.ticktock = audio.loadSound( “sounds/countdown.ogg” )
sfx.correctSound = audio.loadSound( “sounds/success.ogg” )
sfx.wrongSound = audio.loadSound( “sounds/negativebeep.ogg” )
…
return sfx
Then require it in every enterScene()
local sfx = require(“sfx”)
What I am doing, and I think it’s wrong but I’m not 100%, is disposing of it in every exitScene()
package.loaded[“sfx”] = nil
– Note: I’m nilling out all the sounds I use in that scene first (audio.stop() wrongSound = nil audio.dispose() )
Incase you was wondering.
The reason I dispose of the sfx module is that I’m worried about all the sounds that are hanging around, I have 39 of them in there.
Am I doing the right thing here? And if I don’t dispose the sfx when do I?