Hi Folks,
I’m currently updating a variable +1 on tap of an image.
This all works and updates.
My next part is I’m trying to change the sound every time a number is reached.
For example, if the variable reaches 21, it would stop the previous audio and play the next one and so on every time it reaches certain marks.
I managed to do something like that but it slowed down other stuff happening and my thoughts are that it was reloading the sound every time the person tapped and changed the number.
Could someone please assist me and tell me where i’m going wrong.
[lua]local soundScore = 0
local function updateSounds (event)
soundScore = soundScore + 1
hits.text = soundScore --To be deleted.
end
button:addEventListener(“tap”, updateSounds)
– SOUNDS –
if soundScore < 10 then
– Sound
s001 = audio.loadStream( “sound1.wav” )
audio.play( s001, { channel= 7, loops=-1} )
end
if soundScore > 20 then
audio.stop( 7 )
– Sound
s002 = audio.loadStream( “Sound2.wav” )
audio.play( s002, {channels=8, loops=-1} )
end
if soundScore > 30 then
audio.stop( 8 )
audio.dispose ( 8 )
– Sound
s003 = audio.loadStream( “Sound3.wav” )
sChannel = audio.play( s003, { channel=9, loops=1} )
end
if soundScore > 40 then
audio.stop(9)
audio.dispose(9)
– Sound
s004 = audio.loadStream( “Sound4.wav” )
sChannel = audio.play( s004, { channel=10, loops=1} )
end[/lua] [import]uid: 97707 topic_id: 21163 reply_id: 321163[/import]