Hi Developers,
i am using spacemanager/chipmunk i want to Break single shape into multiple small shapes when collided. i am using this code which is already there in spacemanager example code, what it does is it breaks a rectangular shape into multiple rectangular shapes.It creates its own colors for the broken shapes, what i want to do is assign my own sprites to the broken shapes, i have tried the code in comments and it did not work out.
'cpShapeNode *fragShapeNode = (cpShapeNode*)(a->data);
//fragment our shape
NSArray *frags = [fragShapeNode.spaceManager fragmentShape:fragShapeNode.shape piecesNum:16 eachMass:1];
fragShapeNode.shape = NULL;
//step over all pieces
for (NSValue *fVal in frags)
{
cpShape *fshape = [fVal pointerValue];
//cpCCSprite *sRectSprite = [cpCCSprite spriteWithShape:fshape file:@"staticrect.png"];
cpShapeNode *fnode = [cpShapeNode nodeWithShape:fshape];
fnode.color = fragShapeNode.color;
[game addChild:fnode];
// [game addChild:sRectSprite];
}'
All i get is a single static rectangle.
Thanks in advance.