I use Box2D and SFML to create a simple game. However, my object (the ball) does not completely land after it hits the ground. It seems that 50% of the ball went through my border, which looks very uncomfortable. Below are illustrations to illustrate.
Ball to:

Ball After the border hits the ground:

As you can see, 50% of the ball has disappeared (most likely due to displacements or something). Does anyone know how to fix this?
Below is my code for creating an object:
circ_ = sf::CircleShape(radius);
circ_.setOrigin(sf::Vector2f(size.x/2,size.y/2));
circ_.setFillColor(sf::Color(255, 255, 255, 255));
circ_.setOutlineThickness(1);
circ_.setOutlineColor(sf::Color::Black);
bodyDef_.position = b2Vec2(position.x/PIXEL_PER_METER, position.y/PIXEL_PER_METER);
bodyDef_.type = b2_staticBody;
bodyFixtureDef_.density = 1.0f;
bodyFixtureDef_.friction = 0.3f;
bodyFixtureDef_.restitution = 0.8f;
Where is my SFML code, I created a Box2D object using:
Ball basketBall(world, basketBallSize, basketBallPos, 0.0, basketBallRadius, false);
Where is the radius = 32. Can anyone help me? Thanks.
source
share