Sine wave rotate

Hi everybody!

I am trying to implement a “sine wave” rotation, something that “shakes” a picture, but I don’t know where to start.

All I can do is transition.to, but how to achieve a sine wave? Do I have to make listeners that start other transitions, and so on? It seems quite complex that way…

Can you point me in the right direction?
Thanks & Cheers! [import]uid: 94362 topic_id: 33904 reply_id: 333904[/import]

Hello @milicchio,
Since there’s not a builti-in sine wave transition, I suggest two options:

  1. You build a function which repeats a “inOutQuad” easing transition in alternating directions, like this:
local object = display.newCircle( 0, 0, 10 ) ; object.x = 100 ; object.y = 160  
object:setFillColor(255,0,0)  
local targetY = 0 ; local time = 200  
  
local function newTrans()  
 if ( targetY ~= 100 ) then targetY = 100 else targetY = 160 end  
 transition.to( object, { y=targetY, time=time, transition=easing.inOutQuad, onComplete=newTrans } )  
end  
  
newTrans()  
  1. You could program in a table of “pre-determined” values based on a sine-wave pattern, and move your object using a Runtime listener. You can read about this method in the following blog post by Omid Ahourai.
    http://www.coronalabs.com/blog/2012/11/13/predetermined-transitions-manual-animation/

Hope this helps somewhat,
Brent Sorrentino
[import]uid: 200026 topic_id: 33904 reply_id: 134920[/import]

Hello @milicchio,
Since there’s not a builti-in sine wave transition, I suggest two options:

  1. You build a function which repeats a “inOutQuad” easing transition in alternating directions, like this:
local object = display.newCircle( 0, 0, 10 ) ; object.x = 100 ; object.y = 160  
object:setFillColor(255,0,0)  
local targetY = 0 ; local time = 200  
  
local function newTrans()  
 if ( targetY ~= 100 ) then targetY = 100 else targetY = 160 end  
 transition.to( object, { y=targetY, time=time, transition=easing.inOutQuad, onComplete=newTrans } )  
end  
  
newTrans()  
  1. You could program in a table of “pre-determined” values based on a sine-wave pattern, and move your object using a Runtime listener. You can read about this method in the following blog post by Omid Ahourai.
    http://www.coronalabs.com/blog/2012/11/13/predetermined-transitions-manual-animation/

Hope this helps somewhat,
Brent Sorrentino
[import]uid: 200026 topic_id: 33904 reply_id: 134920[/import]