Timer delay question

Hey there guys,

Im having a timer issue.
id like to make a timer so AFTER 2 seconds it does what i need it to do.

i have this but it plays the sound right away.


function tapAbut (event)
if letterCount == 5 and abutSpent == 0 and enteredText.text == secretWord.text and tries > 0 then
goodWordSound()
getWords()
end


now lets say i don’t want goodWordSound() to happen tell 2 seconds later.

how can i do that?

thank you in advance.

cheers
[import]uid: 8094 topic_id: 23424 reply_id: 323424[/import]

This delays the function by 2000 milliseconds

timer.performWithDelay(2000, goodWordSound, 1) [import]uid: 31262 topic_id: 23424 reply_id: 93847[/import]

Worked like a charm :slight_smile:
thank you very much.

Now that was great for sound.

but what if i wanted this inside a timer

transition.to(letterGroup, {time=300, y=300})
thank again [import]uid: 8094 topic_id: 23424 reply_id: 93851[/import]

You can just put that transition in a function and call the function with a timer

[code]
local function moveLetter()
transition.to(letterGroup, {time=300, y=300})
end

timer.performWithDelay(1000, moveLetter, 1)

[/code] [import]uid: 31262 topic_id: 23424 reply_id: 93861[/import]

works like MAGIC …
thank you once again :slight_smile:

cheers

[import]uid: 8094 topic_id: 23424 reply_id: 93863[/import]

Just a quick additional note on transitions - they have a built in delay function. So your code would simplify to:

transition.to(letterGroup, {time=300, delay=1000, y=300})  

Of course, if you wanted to delay more than just the transition effect, performWithDelay is still the way to go.

Full transition.to documentation:
http://developer.anscamobile.com/node/2407 [import]uid: 87138 topic_id: 23424 reply_id: 93885[/import]