How do i keep my sprite form bouncing?

I know this is a dumb question, but when using physics, how can i keep my sprite from bouncing when it collides with the floor?

Ive just started using physics and have been trying for a little bit to figure it out.

Please help

Hello @fluffymonkey69 and welcome to the Corona Labs forums. Just a quick note before I answer your question.

It’s great that you tried to show us your code. There are a couple of things you need to be aware of. First the code doesn’t show where you’re creating your sprite or floor and their physics bodies. The code itself isn’t helpful. Secondly you used a screenshot from your editor. While this is better than no code at all, it’s still not the best way. Many people who would want to help you could take your code and make the required changes and give you the code back… if you code was something that could be copied and pasted. It’s always best to copy and paste code than use screen shots. I’m going to assume you know how to select text, copy and paste it.

There is a trick however. You can either do:

[lua] paste your code in between these two code brackets [/lua]

or simply click the blue <> button in the edit bar in the same row with Bold and Italics and paste your code in the popup window (My preferred way).

Now since I can’t see  your code I’m going to make up some code. You will have to adapt it to your situation. All physics bodies have three parameters that control how they interact:  density: how heavy it is. friction: how much grip it has and bounce: how springy it is. You need to set the bounce value.

local mySprite = display.newSprite( ... parameters to create your sprite ... ) physics.addBody( mySprite, "dynamic", { bounce = 0 } )

That may be all you need to do. However your floor also has some bounce to it and you may find you need to control the floor’s bounce as well :

local floor = display.newRect( ... or however you're creating your floor ... ) physics.addBody( floor, "static", { bounce = 0 } )

That should take care of the issue. Good luck!

Rob

thanks it worked!, and ill definitely post my code the way u suggested for now on

Hello @fluffymonkey69 and welcome to the Corona Labs forums. Just a quick note before I answer your question.

It’s great that you tried to show us your code. There are a couple of things you need to be aware of. First the code doesn’t show where you’re creating your sprite or floor and their physics bodies. The code itself isn’t helpful. Secondly you used a screenshot from your editor. While this is better than no code at all, it’s still not the best way. Many people who would want to help you could take your code and make the required changes and give you the code back… if you code was something that could be copied and pasted. It’s always best to copy and paste code than use screen shots. I’m going to assume you know how to select text, copy and paste it.

There is a trick however. You can either do:

[lua] paste your code in between these two code brackets [/lua]

or simply click the blue <> button in the edit bar in the same row with Bold and Italics and paste your code in the popup window (My preferred way).

Now since I can’t see  your code I’m going to make up some code. You will have to adapt it to your situation. All physics bodies have three parameters that control how they interact:  density: how heavy it is. friction: how much grip it has and bounce: how springy it is. You need to set the bounce value.

local mySprite = display.newSprite( ... parameters to create your sprite ... ) physics.addBody( mySprite, "dynamic", { bounce = 0 } )

That may be all you need to do. However your floor also has some bounce to it and you may find you need to control the floor’s bounce as well :

local floor = display.newRect( ... or however you're creating your floor ... ) physics.addBody( floor, "static", { bounce = 0 } )

That should take care of the issue. Good luck!

Rob

thanks it worked!, and ill definitely post my code the way u suggested for now on