I just started using Corona and am trying to do something that sounds like it should be easy and I haven’t found an answer yet.
I’m creating an object, adding physics to it, then setting the gravityScale to zero so that it doens’t fall. All I want is for it to fall when I tap it but it just sits there.
I know that placing addBody in the jetMove function then setting the gravity does what I’m looking for (makes it fall on tap) but I want the object to have a physics body before I tap it.
Is it possible to change object.gravityScale once the object has been created? Thanks!!
For anyone trying to do this same thing, I think I figured it out. Just turn the object into a sensor, change the gravityScale, then change it back from a sensor. Here’s how the code has changed and it seems to have fixed my problem!
I think it will work if you dont set gravityScale directly in the event listener function. Have you tried creating a timer in the tap listener to change the gracityScale, something like:
[lua]
local function jetMove(event)
timer.performWithDelay( 1, function() jet.gravityScale = 1 end )
For anyone trying to do this same thing, I think I figured it out. Just turn the object into a sensor, change the gravityScale, then change it back from a sensor. Here’s how the code has changed and it seems to have fixed my problem!
I think it will work if you dont set gravityScale directly in the event listener function. Have you tried creating a timer in the tap listener to change the gracityScale, something like:
[lua]
local function jetMove(event)
timer.performWithDelay( 1, function() jet.gravityScale = 1 end )