When I am adding in init() 40 dynamic body i get slow fps...
Here is the code....
What could be the value of hash sizes? or is this correct method ?
cpInitChipmunk();
cpResetShapeIdCounter();
//////
cpBody *staticBody = cpBodyNew(INFINITY, INFINITY);
space = cpSpaceNew();
cpSpaceResizeStaticHash(space, 400.0f, 40);
cpSpaceResizeActiveHash(space, 100, 600);
space->gravity = ccp(0, -80);
space->elasticIterations = space->iterations;
//man
CGPoint verts[] = {
ccp(-10,-10),
ccp(-10,10),
ccp(10,10),
ccp(10,-10),
};
for(int i=0;i<50;i++)
{
int q=arc4random()%5+1;
int xp=160-arc4random()%100;
int yp=240-arc4random()%100;
Sprite *block=[Sprite spriteWithFile:[NSString stringWithFormat:@"%d.png",q]];
[block setPosition:ccp(xp,yp)];
[self addChild:block];
block.scale=0.5;
cpBody *blockBody= cpBodyNew(1.0f,cpMomentForPoly(1.0f, 4, verts, CGPointZero));
blockBody->p = ccp(xp,yp);
cpSpaceAddBody(space, blockBody);
cpShape * shape = cpPolyShapeNew(blockBody, 4, verts, CGPointZero);
shape->e = 0.0f; shape->u = 0.5f;
shape->data = block;
shape->collision_type = q;
cpSpaceAddShape(space, shape);
}