[Resolved] Waiting until transition it's over

Hello there,

I started recently with Lua/Corona (completely beginner) and bit a bit every day I learn new things :slight_smile: but today I tried to join different transitions to simulate a “walking person” something like this

path = {  
 {x = 100, y = 100},  
 {x = 150, y = 100},  
 {x = 200, y = 250},  
 {x = 300, y = 310},  
}  
  
for \_, p in ipairs(path) do  
 transition.to(sprite, { x = p.x, y = p.y, time = 500 })  
end  

The problem it’s what my sprite “run” directly to last position without passing through the positions, someone knows a way to solve this problem, wait until the transition was finished to continue with the next.

Any help was appreciated, thanks a lot!
[import]uid: 147615 topic_id: 27381 reply_id: 327381[/import]

This is because you are calling all the transitions at once - you could use onComplete OR you could use a delay method, like so;

[lua]local sprite = display.newCircle( 150, 100, 30 )
sprite:setFillColor(255, 0, 0)

local tDelay = 0

path = {
{x = 100, y = 100},
{x = 150, y = 100},
{x = 200, y = 250},
{x = 300, y = 310},
}

for _, p in ipairs(path) do
transition.to(sprite, { delay=tDelay, x = p.x, y = p.y, time = 500 })
tDelay = tDelay+500
end[/lua]

Try running that :slight_smile:

Peach [import]uid: 52491 topic_id: 27381 reply_id: 111285[/import]

Thanks a lot Peach! Works great :slight_smile:
[import]uid: 147615 topic_id: 27381 reply_id: 111426[/import]

Not a problem, good luck with your first project :slight_smile: [import]uid: 52491 topic_id: 27381 reply_id: 111470[/import]