Corona Sdk (Orbiting)Rotating Object Around Another Object

I’m trying to rotate object around another object like earth rotates around the sun.

I was wandering if it is possible to do that in corona sdk? And if yes please give some ideas how to do that. here is my code Thanks in advance.

local cer01 = display.newCircle(50,50,50,50)
cer01.x = 200; cer01.y = 400
local cer02 = display.newCircle(25,25,25,25)
cer02.x = 100; cer02.y = 300
local function animate( event )
–cer02(small circle) orbit rotation around cer01(big circle) like earth rotates around the sun.
end
Runtime:addEventListener(“enterFrame”, animate);

Hi ceo.beriapps,

Are you using (or plan to use) the physics engine? This can be done quite easily in that case… see last week’s blog tutorial which explains how to implement “radial gravity” in Corona.

http://www.coronalabs.com/blog/2013/04/09/physics-radial-gravity-and-predicting-trajectory/

If you don’t want to use physics, then you have two additional options:

  1. you can calculate the math and update the orbiting object during a Runtime listener.

  2. you can just place the image on a bigger “canvas” with the object at one end of the canvas, and transparent space elsewhere. Then, place that object center-aligned with the sun, and rotate it using a normal transition. So, it would look like this:

O-----(S)------

(S) is the sun, and the rotating image is the entire row of “dashes”, just transparent except for the “O” object. From a display standpoint, it would look like the object is rotating around the sun. This is ultimately the easiest method, in my opinion.

Best regards,

Brent Sorrentino

Hi ceo.beriapps,

Are you using (or plan to use) the physics engine? This can be done quite easily in that case… see last week’s blog tutorial which explains how to implement “radial gravity” in Corona.

http://www.coronalabs.com/blog/2013/04/09/physics-radial-gravity-and-predicting-trajectory/

If you don’t want to use physics, then you have two additional options:

  1. you can calculate the math and update the orbiting object during a Runtime listener.

  2. you can just place the image on a bigger “canvas” with the object at one end of the canvas, and transparent space elsewhere. Then, place that object center-aligned with the sun, and rotate it using a normal transition. So, it would look like this:

O-----(S)------

(S) is the sun, and the rotating image is the entire row of “dashes”, just transparent except for the “O” object. From a display standpoint, it would look like the object is rotating around the sun. This is ultimately the easiest method, in my opinion.

Best regards,

Brent Sorrentino