# How to draw a curved line in Box2d?

I need to draw a curved line, I have searched the Internet but found nothing that would suit my needs.

I used b2ChainShape but it's not completely what I need.

How can I draw a curved line with Box2d?

You should use b2EdgeShape.

I used this tutorial to achieve a curved collisioning line in Box2D Cocos2dX (the tutorial is in ObjectiveC - C++, but it will give you the idea).

But at the end, it's making little rects making a bigger line that simulates a curved line:

b2BodyDef bd;
bd.position.Set(0, 0);

m_body = m_world->CreateBody(&bd);

b2EdgeShape shape;

b2Vec2 p1, p2;
for (int i=0; i<m_nBorderVertices-1; i++) {
p1 = b2Vec2(((m_borderVertices[i].x  - winSize.width/2)/PTM_RATIO), ((m_borderVertices[i].y - winSize.height/2)/PTM_RATIO));
p2 = b2Vec2(((m_borderVertices[i+1].x - winSize.width/2)/PTM_RATIO) ,((m_borderVertices[i+1].y - winSize.height/2)/PTM_RATIO));
shape.Set(p1, p2);
m_body->CreateFixture(&shape, 0);
}

• i'm tryng all day to implement it , but no luck .... – Alex Nov 18 '14 at 18:03
• Have you filled m_borderVertices with a lot of points (or Vec2, ccp...) simulating a rounded hill? Check out the method -(void)resetHillVertices in this tutorial: link – aramusss Nov 19 '14 at 8:27