Sprites with Physics/Collisions => flying cat

Hello All,

I have been reading the documentation and made a few additions to the “Jungle Scene” to see if i could make the cat fall, hit the ground and continue running, so this is what i added:

[lua]local physics = require(“physics”)
physics.start()
physics.setGravity(0, 9.8)
physics.addBody(instance1, {bounce = 0.2, friction = .2})
physics.addBody(ground, “static”, {bounce = 0.2, friction = .2})[/lua]

the result is that the cat indeed falls, but hits “air” instead of the ground itself, what iam missing here? how can i make this work?

Much appreciated [import]uid: 25410 topic_id: 5385 reply_id: 305385[/import]

I don’t have my Mac running, but from my recent experience, you have a problem with the display groups. I also don’t have the code handy to check this. See in there, maybe there’s a display group that contains everything, so that the background can move opposite of the cat’s movement, thus creating the “moving camera” effect, following the cat. Are the two objects in that display group? [import]uid: 13720 topic_id: 5385 reply_id: 17991[/import]

yeah i have seen this before.

Add this line of code.

physics.setDrawMode ( “hybrid” )

then see how corona sees your object, see if there is a boarder around your cat, even though the images are transparent corona sees them as a solid block, unless you specify the shape of the object.

good luck.
Larry [import]uid: 11860 topic_id: 5385 reply_id: 18008[/import]

Hi,

very helpful, setDrawMode hybrid shows a huge bounding box around the cat, i changed this to:

physics.addBody(instance1, {bounce = 0.2, friction = .2, radius = 70})

and its now a small circle, which makes the tiger really hit the floor.

Thank you! :slight_smile: [import]uid: 25410 topic_id: 5385 reply_id: 18052[/import]