Gravity questions

Hi All,

I am pretty new, only really heard about corona a few days ago, been doing some tests and I love it.

I have a few questions.

  1. Can I set weight on objects, so for example a balloon would float down but a steal beam would plummet ?

  2. I made a demo with a box, then turn on gravity, the box falls down. If I turn the phone upside down, nothing happens, the box just gets stuck to the “ceiling” then. How do I affect the gravity on rotation ?
    Thanks all,
    Trausti [import]uid: 61610 topic_id: 10151 reply_id: 310151[/import]

Check out the shape tumbler example, that example uses the accelerometer to switch gravity.

Otherwise you could just set the supported device orientations in build.settings.
Try that.
lamo78 [import]uid: 13560 topic_id: 10151 reply_id: 37045[/import]

  1. You need to add linear damping to balloon to make it move slowly

  2. gravity vector is defined in your iphone’s frame of reference, that is, rotating iphone , rotates your coordinate system as well and gravity vector will still be defined in same coordinate system.

To achieve what you want, add runtime listener for “accelerometer” event and in the function handler for that listener , set gravity vector according to that event.
e.g

[lua]local function updateG(e)
physics.setGravity(e.xGravity,e.yGravity)
end

Runtime:addEventListener(“accelerometer”,updateG)[/lua]

Note that this will not work in simulator. [import]uid: 48521 topic_id: 10151 reply_id: 37089[/import]