Use More Than One Timer At The Same Time

hello developers i want to make something like that using two timers

timer.performWithDelay(2000,
function()
timer.performWithDelay(1000,
function ()
local position = ObjectsList[j].position
obj= movieclip.newAnim(ObjectsList[j].frames)
obj:play()
obj.x =position[i].x
obj.y=position[i].y
i = i +1
end
,ObjectsList[j].number);
j = j + 1
end
,#ObjectsList)

thats not working with me please help :)
first timer to spawn objects with different location the second to spawn more than one object at the same location

i want to simultaneously spawn objects in different location

thanks in advance

try putting i = 1 after j = j + 1.

you may also have another problem...
when you run the internal function for the first time you will expect the value of j to be 1 but value of j is incremented on the line just after the inside timer.
see the following example

1
2
3
4
5
6
7
8
9
10
11
12
local i
local j = 1
timer.performWithDelay(2600,
function() 
    i = 1; 
    timer.performWithDelay(400,
                                   function () 
                                                                        print("i="..i.."j="..j) ; 
                                                                        i = i + 1 
                                                                end,5); 
        j = j + 1 
end ,5)

thank you @renvis :) thats solve my problem :)

views:1287 update:2011/10/15 21:01:16
corona forums © 2003-2011