Few call transition.to

Hi
i have function

function setWrog(x,y1, tempo, opoznienie)  
 wrog = display.newCircle( x, y1,75 )  
 wrog:setFillColor(255,255,255)   
 physics.addBody(wrog, "static", wrogBody)  
 Gra:insert(wrog)  
 timer.performWithDelay( opoznienie, function()  
 transition.to( wrog, { time=tempo, x=-100, y=y1 } )  
 end, 1 )   
 end  

When i call one function every thing ok Circle go where i want but when i call more times Only one circle go in weird pleace, other stay in her place.

 setWrog(1100,500, 1250, 1000)  
 setWrog(1100,300, 75, 2000)  
 setWrog(1100,100, 2550, 5000)  

What am I doing wrong?
Peace [import]uid: 117910 topic_id: 35883 reply_id: 335883[/import]

Hello,
Have you up-referenced the variable “wrog” above this function? You’re declaring it as a global variable/object, so then when you call the function many times, Lua sees it as the same object.

Best regards,
Brent [import]uid: 200026 topic_id: 35883 reply_id: 142687[/import]

Theres no global declarations, when i declare global variable situations be the same [import]uid: 117910 topic_id: 35883 reply_id: 142714[/import]

Hi again,
What I mean is, you should declare “wrog” as local, in the loop.

local wrog = display.newCircle( x, y1,75 )

Also, you can just do a delay on the transition and skip the timer, as such:

transition.to( wrog, { time=tempo, delay=opoznienie, x=-100, y=y1 } )

Hello,
Have you up-referenced the variable “wrog” above this function? You’re declaring it as a global variable/object, so then when you call the function many times, Lua sees it as the same object.

Best regards,
Brent [import]uid: 200026 topic_id: 35883 reply_id: 142687[/import]

Theres no global declarations, when i declare global variable situations be the same [import]uid: 117910 topic_id: 35883 reply_id: 142714[/import]

Hi again,
What I mean is, you should declare “wrog” as local, in the loop.

local wrog = display.newCircle( x, y1,75 )

Also, you can just do a delay on the transition and skip the timer, as such:

transition.to( wrog, { time=tempo, delay=opoznienie, x=-100, y=y1 } )

Hello,
Have you up-referenced the variable “wrog” above this function? You’re declaring it as a global variable/object, so then when you call the function many times, Lua sees it as the same object.

Best regards,
Brent [import]uid: 200026 topic_id: 35883 reply_id: 142687[/import]

Theres no global declarations, when i declare global variable situations be the same [import]uid: 117910 topic_id: 35883 reply_id: 142714[/import]

Hi again,
What I mean is, you should declare “wrog” as local, in the loop.

local wrog = display.newCircle( x, y1,75 )

Also, you can just do a delay on the transition and skip the timer, as such:

transition.to( wrog, { time=tempo, delay=opoznienie, x=-100, y=y1 } )

Hello,
Have you up-referenced the variable “wrog” above this function? You’re declaring it as a global variable/object, so then when you call the function many times, Lua sees it as the same object.

Best regards,
Brent [import]uid: 200026 topic_id: 35883 reply_id: 142687[/import]

Theres no global declarations, when i declare global variable situations be the same [import]uid: 117910 topic_id: 35883 reply_id: 142714[/import]

Hi again,
What I mean is, you should declare “wrog” as local, in the loop.

local wrog = display.newCircle( x, y1,75 )

Also, you can just do a delay on the transition and skip the timer, as such:

transition.to( wrog, { time=tempo, delay=opoznienie, x=-100, y=y1 } )