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?

Well
Wouldn't something like this work

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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)
views:1525 update:2011/9/28 21:38:26
corona forums © 2003-2011