I want to make a moon rotating around a planet, or something along that analogy. So is there something I can call for physics.setGravity(0,0) that changes the position that the gravity pulls towards, particularly assigning that to be a physics body? If not, simply a specific x-y coordinate will be fine.
local moon = display.newImage ("moon.png")
physics.addBody(moon, {bounce=0, density=1.0})
local earth = display.newImage ("earth.png")
physics.addBody(earth, {bounce=0, density=1.0})
Thanks
Instead of playing around with the
setGravityoption, I think you should just rotate the images using something like this:Notice that I am not really mucking about with
setGravity, but the speed of the rotation is defined in theorbitfunction.The above code assumes you just have image files to represent your planetary bodies. If so, you will have to play around with the constants above (
earth.xandearth.y, scaling values, etc) to make the whole system LOOK right for the images you choose.Good luck!