Box2D Forums

It is currently Mon May 20, 2013 5:48 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Fri Jul 29, 2011 8:07 pm 
Offline

Joined: Fri Jul 29, 2011 10:28 am
Posts: 2
hi,
I am new to box2d.(using cocos2d box2d application)
I am drawing lines in cctouchmoved. I want to perform some action when current line has touched any previously drawn lines.
this is the box2d code for line


b2BodyDef bd;
bd.type = b2_staticBody;
bd.position.Set(0, 0);
b2Body* body = world->CreateBody(&bd);


b2PolygonShape shape;
shape.SetAsEdge(b2Vec2(start.x, start.y), b2Vec2(end.x, end.y));

_lineFixture = body->CreateFixture(&shape,0.0f);


Top
 Profile  
 
PostPosted: Fri Jul 29, 2011 11:35 pm 
Offline

Joined: Tue Jun 24, 2008 8:25 pm
Posts: 1515
Location: Tokyo
Box2D has no feature for this, so you will need to check yourself if the segment about to be drawn will cross over an existing segment. You might find this helpful http://softsurfer.com/Archive/algorithm ... _0104B.htm


Top
 Profile  
 
PostPosted: Sun Jul 31, 2011 7:27 am 
Offline

Joined: Fri Jul 29, 2011 10:28 am
Posts: 2
Thank you. you saved my time i have searched almost all the pages having box2d in it. Now its clear i can think of something else.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group