Repeat Transition

Hi,

I’m trying to move an object up and down in a loop. The following is what I have to move an object vertically and I need this transition reversed and then to repeat, so that the object moves up and down.

local dest2 = display.newImage (“dest2.png”)

local vbar2 = display.newImage (“vbar2.png”)

dest2.x = 240

dest2.y = 125

vbar2.x = 240

vbar2.y = 160

transition.to(vbar2, { time = 10000, x = dest2.x, y = dest2.y } )

localGroup:insert(vbar2)

I’ve checked the API but perhaps I’m missing something really simple, I’ve tried a couple of the samples from the API but could only find move-fade

Any help would be much appreciated.

Thanks!

[lua]

local function loopObject()

  local objectDown= function()

    transition.to(vbar2, { time=10000, y=160, onComplete=loopObject })

  end

  transition.to(vbar2, { time=10000, y=125, onComplete=objectDown })

end

loopObject()

[/lua]

Sorted!

Thanks a mill Nick!!

That was speedy :) 

[lua]

local function loopObject()

  local objectDown= function()

    transition.to(vbar2, { time=10000, y=160, onComplete=loopObject })

  end

  transition.to(vbar2, { time=10000, y=125, onComplete=objectDown })

end

loopObject()

[/lua]

Sorted!

Thanks a mill Nick!!

That was speedy :)