i’ve playing with cheetomoskeeto’s orb smasher tutorial at http://www.youtube.com/watch?v=6TsDdLY7VXk and am having an issue adding a delay when i want the listener to receive variables…
placing random orbs on the screen is no issue, get a nice delay of whatever i want using timer.performWithDelay
When you put () that calls the function immediately.
You may be able to work around this however by making the parameters into properties of the timer. I’m not at home to test if this works, but you might try:
[code]
local function spawnEgg(event)
print(event.msg)
end
local tmr = timer.performWithDelay(200, spawnEgg, 1)
tmr.msg = “This is a test.”
[/code] [import]uid: 12108 topic_id: 6437 reply_id: 22264[/import]
ok this is probably quite bad because it creates multiple timers but i’m just showing how to pass variables on a timer. I wouldn’t use this method
[lua]function spawnEgg(event)
local t = event.source – the timer
local params = t.params – our assigned variable
print(params.i,params.j)
print(t.blah) – “whatever”
end
for i = 1, egg_columns do
for j = 1, egg_rows do
local delay = 200 * (((i-1)*egg_rows) + j)
local tmr = timer.performWithDelay(delay, spawnEgg, 1);
tmr.params = {i=i, j=j}-- assign a variable to the timer, along with some values
tmr.blah = “whatever”
end
JMP: I think my hacked android tablet would explode with all those timers! Have you tried that in the simulator? I’ll give it a shot tonight. Thanks! [import]uid: 24493 topic_id: 6437 reply_id: 23215[/import]