Transitions - animate objects in the same scene

Hello

I’m trying to set up a series of transitions, where one transition runs e.g.-

transition.to(show2, { time = 12000, x = dest1.x, y = dest1.y, yScale=2, xScale=2})

Then I would like to pause this object, resume the object but change the direction. When I add all transitions into one line, they all merge together without a definite path. I’ve checked the transitions documentation and couldn’t find anything that relates to this.

I also wanted up to ten objects to follow the same path, proceeding each other. I’ve also tried this but all the objects run at the same time. 

Is there a way to set a timer, to allow each object to run its path, with a change of direction, then the next object runs its path etc?

Thanks in advance!

You might be better plotting out the path with the transitions, rather than trying to figure out a way to pause, change a variable in the transition, and resume the transition. That way, you can create all of your objects and transitions in their own tables, within their own function, and just call it on a timer.

Something like:

 local transHolder = {} local objectHolder = {} local function createObjsTrans() for i=1, 10 do objectHolder[i] = display.newRect(0,100+(i\*20), 10,10, true) local function moveSecond() transHolder[#transHolder+1] = transition.to(objectHolder[i], {time=3000, x=objectHolder[i].x-100}) end transHolder[#transHolder+1] = transition.to(objectHolder[i], {time=3000, x=objectHolder[i].x+100, delay=1000+(i\*500), onComplete=moveSecond}) end end createObjsTrans()

Thanks a mill Alex, that works a treat, much appreciated.

:slight_smile:

You might be better plotting out the path with the transitions, rather than trying to figure out a way to pause, change a variable in the transition, and resume the transition. That way, you can create all of your objects and transitions in their own tables, within their own function, and just call it on a timer.

Something like:

 local transHolder = {} local objectHolder = {} local function createObjsTrans() for i=1, 10 do objectHolder[i] = display.newRect(0,100+(i\*20), 10,10, true) local function moveSecond() transHolder[#transHolder+1] = transition.to(objectHolder[i], {time=3000, x=objectHolder[i].x-100}) end transHolder[#transHolder+1] = transition.to(objectHolder[i], {time=3000, x=objectHolder[i].x+100, delay=1000+(i\*500), onComplete=moveSecond}) end end createObjsTrans()

Thanks a mill Alex, that works a treat, much appreciated.

:slight_smile: