I am very new to Chipmunk and I wonder how you create rouge shapes. From what I could read, rouge shapes are shapes that its body are not added to the space. But you still create their bodies?
Let me explain my need.
Right now, I have made so that I can spawn small balls into a rectangle and fill it up.
But now I want to create a polygon cog that will spin around inside the rectangle and tumble around the balls. You understand? I think I have achieved it, but now fully. Right now I just have a polygon in form of a rectangle and whenever I rotate it, the balls goes trough the rectangle like jelly almost. Let me show you the code.
This is me, creating a rouge shape. I never add it to space.
Code: Select all
cpVect* vertices = new cpVect[4];
vertices[0].x = 0; vertices[0].y = 100;
vertices[1].x = 100; vertices[1].y = 100;
vertices[2].x = 100; vertices[2].y = 0;
vertices[3].x = 0; vertices[3].y = 0;
cpBody* cBody = cpBodyNewStatic();
cpBodySetPos(cBody, cpv(300, 300));
cpShape* cShape = cpPolyShapeNew(cBody, 4, vertices, cpvzero);
cpSpaceAddShape(space, cShape);
cpShapeSetElasticity(cShape, 0);
cpShapeSetFriction(cShape, 0);
Code: Select all
cpBodySetAngle(cBody, thor::toRadian<float>(45));
cpSpaceReindexShapesForBody(space, cBody);