Hello,
I have a problem with my app and i need your help. What I want to achieve is the following. I have a timer and during the countdown (before the countdown achieves zero value), i want to play a series of beep (sound). The number of iteration to play the beep series is random and the delay to start playing the beep sounds series is also random. I have already write the code to do those things (please, watch the Beep() function).
What i want is the following!
Step 1: Start the timer
Step 2: Play the beep sound series. It will start to play at a random delay and will have a random iteration (my function Beep)
Step 3: Make a pause of the beep sounds function (random seconds)
Step 4: if the countdown is active again (with a value different of zero) so repeat the Step 2 and Step 3. These two steps will stop only if the countdown achieves zero
My problem is step 3 and step 4. Can you help me with that please? Thanks for your next reply
Here is my test code.
local son\_beep=audio.loadSound("beep.wav"); local duree\_round\_restant=60; local function Beep() local beep\_delay=math.random(3000,7000) function declencherBeep() local beep\_iteration=math.random(2,5) timer.performWithDelay(1000, function() audio.play(son\_beep); end, beep\_iteration) end timer.performWithDelay(beep\_delay, declencherBeep) end local function updateDureeRound() duree\_round\_restant=duree\_round\_restant-1 minutesDureeRound=math.floor(duree\_round\_restant/60) secondesDureeRound=duree\_round\_restant % 60 local time=string.format( "%02d:%02d", minutesDureeRound, secondesDureeRound) duree\_round\_value.text=time end duree\_round\_value=display.newText("00:00", display.contentCenterX, 80, native.systemFont,55) Beep() timer.performWithDelay(1000, updateDureeRound, duree\_round\_restant);