Devyn
Devyn

Reputation: 2285

iOS wiggle animation in Corona SDK?

I've problem animating wiggle effect from iOS in Corona SDK. It's now vibrating but not quite similar.

-- Animation.new(p1.img) // how to call from main.lua

module(..., package.seeall)

function new(obj)
    obj.x = 150
    obj.y = 150
    local ox = obj.x
    local oy = obj.y

    function obj:timer(e) ----- reset the position of object back to it's original
        local function reset()
            obj.x = ox; obj.y = oy
            print("reset called...")
        end

        local t=25
        self:setReferencePoint(display.CenterReferencePoint)
        transition.to(self, { time=t, x=obj.x+4, rotation=5, transition=easing.outExpo, onComplete=listener2})
        transition.to(self, { time=t, delay=t, x=obj.x-8, rotation=-10, transition=easing.outExpo, onComplete=reset})
    end

    timer.performWithDelay(150, obj, 20)

end

Upvotes: 1

Views: 1877

Answers (1)

Devyn
Devyn

Reputation: 2285

Simply changing two transition.to lines to following will give similar effect.

transition.to(self, { time=t,  rotation=4, transition=easing.outExpo, onComplete=listener2})
transition.to(self, { time=t, delay=t, rotation=-3, transition=easing.inExpo, onComplete=reset})

Upvotes: 2

Related Questions