Skip to content

Instantly share code, notes, and snippets.

View nadar71's full-sized avatar
🏠
Working from home

Simone Mapelli nadar71

🏠
Working from home
View GitHub Profile
-- Corona Game SDK example of how to let two bodies circle each other by applying a continuous, attracting force
--
-- The example uses the physics engine, sets gravity to 0, creates two balls separated in the x-direction,
-- with initial speeds in opposite y-direction.
-- Thru an enterFrame event handler, an attracting force is continuously applied to both balls with body:applyForce().
-- The force is normalized over the distance between the two balls.
-- By playing with the initial speed and force factors, you can make the balls spin faster/slower in circles or ellipses
--
-- Save this file as "main.lua" in a project directory and load it in the simulator
--