1

Is there a way to prevent the characters starting at the same time? I tried this but every single character still starts the action the moment the animation starts even if I added the delay.

--runningPG1.. runningPG5 have attached a sprite and coordinates
arrayPg = {runningPG1, runningPG2, runningPG3, runningPG4, runningPG5}

for key, value in pairs(arrayPg) do 
    transition.to(value, { y = value.y+350, time = 1500})
    transition.to(value, { x = value.x-740, time = 2500, delay = 1550 })
    transition.to(value, { y = value.y+825, time = 2500, delay = 4100 })
end
Austin Greco
  • 32,997
  • 6
  • 55
  • 59
Jello
  • 11
  • 1

1 Answers1

1

If you want each one to start at a different time, I think you would need to add a delay based on the number in the loop. Something like:

--runningPG1.. runningPG5 have attached a sprite and coordinates
arrayPg = {runningPG1, runningPG2, runningPG3, runningPG4, runningPG5}

baseDelay = 0
for key, value in pairs(arrayPg) do 
    transition.to(value, { y = value.y+350, time = 1500, delay = baseDelay })
    transition.to(value, { x = value.x-740, time = 2500, delay = baseDelay + 1550 })
    transition.to(value, { y = value.y+825, time = 2500, delay = baseDelay + 4100 })
    baseDelay = baseDelay + 500
end

or you could use a random delay also

for key, value in pairs(arrayPg) do 
    baseDelay = math.random(0, 2000)
    transition.to(value, { y = value.y+350, time = 1500, delay = baseDelay })
    transition.to(value, { x = value.x-740, time = 2500, delay = baseDelay + 1550 })
    transition.to(value, { y = value.y+825, time = 2500, delay = baseDelay + 4100 })
end
Austin Greco
  • 32,997
  • 6
  • 55
  • 59