# Cocos2dx - Create the friction of the ground

I'm writing a game, it a pool game. I've read about cocos2dx + physics library, however the document is really poor to understand.

Material has 3 attributes (http://www.cocos2d-x.org/wiki/Physics#) : - Density (?) - Friction (?) - Restitution (scale from 0 to 1)

Execept the restitution has limitation value from 0 to 1. I don't know what's density and the limitation of friction value?

If i want to create a ball and when it collide to the bound/wall, it bounce back, and the ground has friction to slow down the ball during running, how can i do it?

First of all you need to make sure your Scene is created with physics enabled. You do this by calling auto scene = Scene::createWithPhysics(); where relevant in your code. If not, none of the physics you'll try will work.

Next, you shouldn't pay too much attention to the material right now, what you should probably focus on is the PhysicsBody class and its methods and variables.

For instance, if I were to make a simple ball physics object I'd do something like this : 

auto sprite = Sprite::create("ball.png");
auto physicsBody = PhysicsBody::createCircle(16.0f); // 16 being the radius of the circle
sprite->setPhysicsBody(physicsBody);

Repeat this a few times, changing the setVelocity(Vec2(x, y)); as needed, see if you can get a bunch of balls moving around on the screen. I believe they will bump into each other by default. You could also use physicsBody->applyForce(Point(x, y)); or physicsBody->applyImpulse(Point(x, y));.
You can create a physics body for a sprite with a specified material. This would look something like. groundSprite->setPhysicsBody(PhysicsBody::createBox(boxSize, PhysicsMaterial(0.1f, 0.5f, 0.7f)));` where the last parameter is the friction parameter like OP mentioned. Play around with it until your ball comes to a stop where/when you want it to.