is there a better way than this to alternate a transition on an object?

is there a better way than this to alternate a transition on an object?

local reverse = 0 local tim1, t1 local testButton = \<\<your object\>\> &nbsp;&nbsp;&nbsp;&nbsp;local function wobbleButton (event) &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;if reverse == 0 then &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;reverse = 1 &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;t1 = transition.to( testButton, { rotation = -30, time=100 } ) &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;else &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;reverse = 0 &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;t1 = transition.to( testButton, { rotation = 30, time=100 } ) &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;end &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tim1 = timer.performWithDelay( 100, wobbleButton)&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;end &nbsp;&nbsp;&nbsp;&nbsp;tim1 = timer.performWithDelay( 10, wobbleButton)&nbsp;&nbsp;&nbsp;&nbsp; if t1 then transition.cancel(t1) end if tim1 then timer.cancel(tim1) end &nbsp;

I think what you’re looking for is a continuous transition loop? If so, here is a good way to accomplish it:

        local function trans1()

            local function trans2()

                transition.to(testButton, {time=100,rotation=30,onComplete=trans1})

            end

            transition.to(testButton, {time=100,rotation=-30,onComplete=trans2})

        end

        trans1()

thanks - that looks a bit shorter, two transitions but no timers

I think what you’re looking for is a continuous transition loop? If so, here is a good way to accomplish it:

        local function trans1()

            local function trans2()

                transition.to(testButton, {time=100,rotation=30,onComplete=trans1})

            end

            transition.to(testButton, {time=100,rotation=-30,onComplete=trans2})

        end

        trans1()

thanks - that looks a bit shorter, two transitions but no timers