Box2D Forums

It is currently Mon May 20, 2013 2:49 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Round physics container
PostPosted: Wed Sep 28, 2011 10:41 pm 
Offline

Joined: Wed Sep 28, 2011 10:36 pm
Posts: 1
Hi! I'm starting working with Box2D on Flash platform. I choose it cause i need to do such a thing: a circle with the small car inside of it, we can change the circle radius, car speed (force?) and car mass; then if the speed is to small the car will not reach the top of the circle and will fall down. All I need to know is if it possible to do using Box2D and if it is, how to create a circle in which a car will drive? It must be created like a physics container or like a shape? Thank you for help.

Is nobody really know if it is possible? If you know that it-s impossible just write me. But if it is please say how to create such a thing.


Top
 Profile  
 
PostPosted: Thu Oct 06, 2011 3:33 am 
Offline

Joined: Tue Jun 24, 2008 8:25 pm
Posts: 1515
Location: Tokyo
You could make a ring of polygons or edge shapes.
It might be tricky to change the size of the ring, but I guess if you are only concerned about the interior of the ring for your game, you could make each segment very long and move them all inwards or outwards to change the size.


Top
 Profile  
 
PostPosted: Fri Oct 21, 2011 8:35 am 
Offline

Joined: Mon Oct 10, 2011 4:34 pm
Posts: 15
Irresistible force has the right idea here, just use something like this to add edges to a body:


var radius:Number = 100;
var numSegments:Number = 24;
var twoPi:Number = Math.PI * 2;

for ( var ct:int = 0 ; ct < numSegments ; ct++) {

addVertex( Math.cos( (ct / numSegments) * twoPi) * radius , Math.sin( ct/numSegments * twoPi) * radius );

}

You might need to add the edges back-to-front, but that should do it.


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