I would like to create a rotationg wheel with chipmunk which means one main circle and couple of edges
Code: Select all
// Create the body
Entity.m_PhysicBody = cpBodyNew(fMass, fMoment);
Entity.m_PhysicBody->p = [RESOURCES ConvertCocos2DPointToChipmunkPoint:PPosition];
cpBodySetAngle(Entity.m_PhysicBody, fAngle);
cpSpaceAddBody(space, Entity.m_PhysicBody);
// Create the Circle
Entity.m_PhysicShape = cpCircleShapeNew(Entity.m_PhysicBody, Radius, cpvzero);
Entity.m_PhysicShape->e = 0;
Entity.m_PhysicShape->u = 0;
Entity.m_PhysicShape->data = Entity.m_EntitySprite;
Entity.m_PhysicShape->collision_type = 0;
cpSpaceAddShape(space, Entity.m_PhysicShape);
// Create the Rectangles
// Define our shape's vertexes
int width = 30;
int height = 35;
cpVect verts0[4] = {cpv(-width/2,height/2), cpv(width/2, height/2), cpv(width/2, -height/2), cpv(-width/2,-height/2)};
float angle = (2*3.14)/Edges;
float currentangle = 0;
int offset = Radius + width/2;
for (int i=0; i<Edges; i++) {
// Create a obstacle
Entity.m_PhysicShape = cpPolyShapeNew(Entity.m_PhysicBody, 4, verts0, cpv(cos(currentangle)*offset,sin(currentangle)*offset));
Entity.m_PhysicShape->e = 0.3;
Entity.m_PhysicShape->u = 0.3;
Entity.m_PhysicShape->data = tempsprite;
Entity.m_PhysicShape->collision_type = 0;
cpSpaceAddShape(space, Entity.m_PhysicShape);
currentangle += angle;
}
Thanks for your time