Hi,
Playing around with Corona and i'm asking myself: how to create an object (like a balloon) which can defie gravity and go 'up'.
Have tried several thinks but the balloon always falls. Maybe i'm missing something.
Glad if someone can help me :)
Thanks !
You need to constantly apply small upward linear impulses to the balloon:
1
2
3
4
5
| local function defyGravity()
balloon:applyLinearImpulse( 0, -10, balloon.x, balloon.y )
end
Runtime:addEventListener( "enterFrame", defyGravity) |
Excellent ! Thanks Raul just what I was looking for !
A better way would be to set linear velocity
1
2
3
| local function defyGravity()
balloon:setLinearVelocity(0,-10)
end |
are you using physics ?
in that case you can just use a -ve value for gravity.
physics:setGravity(0,-5)
ofcourse only if there are no other object which should fall down. :)
views:1721 update:2011/10/18 15:01:22