Hello everyone..
I am working on an app, in which i do need to move some balls inside a circle (a hollow circle). the ball can move across the inner perimeter of circle.What approach should i use..?? Is there any inbuild functionality to implement this or any other method.
any help will be appriciated.
I also need the same. Do anyone have an idea.
Hi sunil,
I solved the problem and its working awesome now.I found out that there is nothing like a hollow circle in box2d, so u will have to create ur own circle made of small lines.each line should be dynamic. now whatever object u put inside that circle, when it will touch the circle perimeter, it will collide with respective line and this way wont cross circle perimeter and will move only inside circle.
hope, it will solve ur problem, if need more help, can tell me again.
thanks ankur for the reply. I am new to box2d, some code will help me more. If i get you, i have to make circle with line parameter, ok now when ball touches will maximum lines, then it will not collide with the lines, by which ball will move to the ground. right?
Thanks & regards,
Sunil
Thanks for the useful info ankur. after again read your post, i get understand the solution. But i have one question why we need it dynamic?
My code:-
-(void) makeCircleBoundary
{
//a static body
b2BodyDef myBodyDef;
myBodyDef.type = b2_staticBody;
//myBodyDef.position.Set(0, 0);
myBodyDef.userData = basketCostume;
b2Body* circleBody = world->CreateBody(&myBodyDef);
//shape definition
b2PolygonShape polygonShape;
//fixture definition
b2FixtureDef myFixtureDef;
myFixtureDef.shape = &polygonShape;
//add circle lines
polygonShape.SetAsEdge(b2Vec2(367/RATIO,181/RATIO), b2Vec2(389/RATIO,181/RATIO));
circleBody->CreateFixture(&myFixtureDef);
polygonShape.SetAsEdge(b2Vec2(351/RATIO,178/RATIO), b2Vec2(363/RATIO,177/RATIO));
circleBody->CreateFixture(&myFixtureDef);
polygonShape.SetAsEdge(b2Vec2(344/RATIO,173/RATIO), b2Vec2(351/RATIO,173/RATIO));
circleBody->CreateFixture(&myFixtureDef);
polygonShape.SetAsEdge(b2Vec2(342/RATIO,167/RATIO), b2Vec2(348/RATIO,167/RATIO));
circleBody->CreateFixture(&myFixtureDef);
polygonShape.SetAsEdge(b2Vec2(348/RATIO,162/RATIO), b2Vec2(353/RATIO,162/RATIO));
circleBody->CreateFixture(&myFixtureDef);
polygonShape.SetAsEdge(b2Vec2(356/RATIO,157/RATIO), b2Vec2(368/RATIO,157/RATIO));
circleBody->CreateFixture(&myFixtureDef);
polygonShape.SetAsEdge(b2Vec2(366/RATIO,154/RATIO), b2Vec2(393/RATIO,154/RATIO));
circleBody->CreateFixture(&myFixtureDef);
polygonShape.SetAsEdge(b2Vec2(406/RATIO,158/RATIO), b2Vec2(406/RATIO,162/RATIO));
circleBody->CreateFixture(&myFixtureDef);
polygonShape.SetAsEdge(b2Vec2(417/RATIO,170/RATIO), b2Vec2(426/RATIO,170/RATIO));
circleBody->CreateFixture(&myFixtureDef);
polygonShape.SetAsEdge(b2Vec2(407/RATIO,174/RATIO), b2Vec2(416/RATIO,174/RATIO));
circleBody->CreateFixture(&myFixtureDef);
}
Secondly, when i make the circle boundary it never go inside, it collides at every case. Could you please help me in this regard.
sorry i have no idea.......