I have 12 buttons on my main menu page, and each has a different sound when you click on one of them, do I have to add 12 event listeners to each stop and dispose function of each sound anytime, anyone of the buttons are hit? If that makes any sense
Hmm… I haven’t tested this personally, but you can try something like this:
[lua]local buttonPress = function (event)
if event.phase == “Released” then
if button1.press == true then
– do something
elseif button2.press == true then
– do something else
end
end
end
Alternatively, you can write just one audio callback function which you reuse for everything you play.
function MyAudioCallback(event)
audio.dispose(event.handle)
end
-- sound is the handle loaded by audio.loadSound or audio.loadStream
function MyPlaySound(sound)
audio.play(sound, {onComplete=MyAudioCallback})
end
If you plan to reuse these sounds a lot and aren’t tight on memory, you might just keep the sounds in memory and skip disposing them. [import]uid: 7563 topic_id: 9421 reply_id: 34476[/import]
Nothing to contribute… but just wanted to comment/ask…
are you Matthew “Chandler” Perry ? hehheheh… [import]uid: 48521 topic_id: 9421 reply_id: 34485[/import]