issues with creating a timer.

Hi, I’m new to corona, I have made a few games in gamesalad but decided to learn corona for the advanced features.

I was getting along great in converting a game over to corona until I hit a problem I thought would be simple.

I have a hoop image which spawns in the centre of the screen and grows to larger than the screen then destroys itself. This bit is fine.

A hoop is spawned every 3 seconds initially, then when the game level increases it should spawn every 2 then 1 seconds.

I have a timer which performs with a delay that is given by a variable called “delay” to spawn the hoops. however when the value of “delay” changes, the timer doesn’t update and change the spawn speed. Does anybody have an answer or any help at all?

Thanks for any responses!

Gary [import]uid: 8699 topic_id: 5106 reply_id: 305106[/import]

My hunch would be to cancel the timer when the game level increases and create a new one with the new delay parameter.

This code might help:
http://developer.anscamobile.com/node/4706
[import]uid: 9659 topic_id: 5106 reply_id: 16918[/import]

thanks, but I was just about to post stating I had solved it.

I fixed it by having a function which runs every frame, it checks for a value for the game level and whether or not the hoopspawn trigger is 1. if the trigger is 1 then it spawns a hoop, changes the trigger to 0 then after the required time, it sets the trigger back to 1, to allow the next hoop to spawn.

this allows me to have an IF rule for each colour/speed hoop I need to spawn, and choose when and what speed to do it.

Thanks for the reply, that code is what I found to help me understand the timers! [import]uid: 8699 topic_id: 5106 reply_id: 16919[/import]