Circle Collision?

So I’m a little confused on the Circle collision provided by the Box2D.h library.

In it, I’m not sure where to find how big I can make it (by how large the radius is). Also, is the TestPoint function in b2CircleShape.h a function to test if a point is colliding with the Circle?

And is there any way to make the Circle stay in the position of an object that is moving around in relation to the object? For instance, I have a rectangular object that the top area will have the Circle shape. I want that to stay in that exact position with the object whenever the object is moved around. Do I have to constantly update the position of the object?

Change circle radius with m_radius:

circle->m_radius = 12.0f/PTM_RATIO;

To do the circular top on a rectangle you almost certainly want to assign two Fixtures, with the 2 Shapes, to the Body you created. It will be PART of the object so it will stay in position. More info here: http://www.box2d.org/manual.html#_Toc258082972

I didn’t mean there would be two shapes. I meant that there would be the rectangular sprite (not a b2Shape), and then I would make a b2Shape of a Circle at the top of that image (so it’s covering about a third of the image).

Does this mean I only need to create 1 fixture?

Also what is PTM_RATIO? I need the sizes of this to be in pixels too. I’d like to be able to set the size of the Circle so it is where I want.

PTM_RATIO is a constant often used to store the Pixel-to-Meter ratio for conversion between box2d and cocos2dx.

You would only need one fixture if you have one shape.

So I just use it, it doesn’t really affect how big it is? For instance, circle->m_radius = 12.0f/PTM_RATIO; you put in before would be a 24 pixel circle?

Also, how do I include it into a project that was made just using the cocos2d-x regular project? I tried including the Box2D into the lib and then including it in my GameScene, but that just gives me thousands of errors.

Yes, that would be a 24 pixel circle, with a 12 pixel radius. However Box2d wants to know how big it is in meters, because Box2d isn’t using pixels. So if you want that object to be a 3 meters across you want to include in your header somewhere:

const int PTM_RATIO = 8.0;

I’m gonna let someone else help with getting Box2d in, it’s a pain and I had enough trouble myself.