Code: Select all
//Create "container" to hold things that are inside the bowl
int num = 8;
CGPoint verts[] = {
cpv(-11.5f, 33.2f),
cpv(9.9f, 31.9f),
cpv(33.1f, 8.1f),
cpv(33.2f, -8.5f),
cpv(9.9f, -34.2f),
cpv(-17.2f, -28.3f),
cpv(-34.2f, -1.4f),
cpv(-29.8f, 18.3f)
};
_containerBody = [ChipmunkBody bodyWithMass:15.0f andMoment:cpMomentForPoly(15.0f, num, verts, cpvzero)];
for (int i = 0; i < 8; i++){
cpVect point1 = verts[i];
cpVect point2 = verts[(i + 1) % 8];
ChipmunkShape *segmentShape = [ChipmunkSegmentShape segmentWithBody:_containerBody from:point1 to:point2 radius:10.0f];
[segmentShape setElasticity:0.5f];
[segmentShape setFriction:0.0f];
[segmentShape setLayers:10];
[_space addShape:segmentShape];
}
[_space addBody:_containerBody];