我在Corona SDK中从iOS动画制作摆动效果的问题。它现在振动但不太相似。
-- 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
答案 0 :(得分:2)
简单地将两个transition.to行更改为以下将产生类似的效果。
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})