Metronome Engine, Need some help and ideas from other developers.

HI,
I am trying to develop a metronome system that fires events at a particular time. For example. Say I want the metronome to fire every 500ms if an event happens between the two beats the metronome engine delays action to the next beat. If you have no idea what I am talking about please read this article.

http://gl33k.com/blog/2011/6/27/a-metronome-for-everyone.html

I am wondering how to do this in corona. I am thinking about custom events, but I am not really sure. I was looking over the state machine tutorial and was thinking something like that would work. But I am really not sure how to approach this.

Any suggestions? [import]uid: 8192 topic_id: 11971 reply_id: 311971[/import]

Well
Wouldn’t something like this work

local functions = {} --create table  
local function addFunction(func)  
 table.insert(functions,func)  
end  
local function processFunctions()  
 for k,v in pairs(functions) do  
 v()  
 end  
 functions = {}  
end  
timer.performWithDelay(500,processFunctions,0)  
--  
--  
--example of use  
local function listener1(event)  
 addFunction(  
 function()  
 print(event.object1.x,event.object1.y)  
 end  
  
}  
end  
  
Runtime:addEventListener("collision",listener1)  

something like that?
I know timer.performWithDelay isnt overly accurate, but I’m low on time to answer, the boss is nagging me to get back to work :wink:
If you want something more accurate, use system.getTimer() and enterFrame

[import]uid: 34945 topic_id: 11971 reply_id: 43678[/import]