I have multiple b2BodyS created like so:
Donut *donut = [Donut spriteWithFile:@"donut.png"]; //Donut is my custom subclass of CCSprite
[self addChild:donut z:1];
b2Body *body;
b2BodyDef ballBodyDef;
ballBodyDef.type = b2_dynamicBody;
ballBodyDef.position.Set(donut.position.x/PTM_RATIO, donut.position.y/PTM_RATIO); //PTM_RATIO is 32
ballBodyDef.userData = donut;
body = world->CreateBody(&ballBodyDef);
b2CircleShape circle;
circle.m_radius = donut.textureRect.size.width*donut.scale/2/PTM_RATIO;
b2FixtureDef ballShapeDef;
ballShapeDef.shape = &circle;
ballShapeDef.density = 1.0f;
ballShapeDef.friction = 0.5f;
ballShapeDef.restitution = 0.8f;
body->CreateFixture(&ballShapeDef);
My Donut class has a CCRepeatForever action where it scales up and down, etc...
For my b2Body, I destroy and create a new fixture which reflects the current size of my CCSprite. I do this every frame by following this thread:
viewtopic.php?f=8&t=5601&p=26070#p26070I should also mention that I apply a force to all my bodies upon creation so it moves and bounces off the edges I've created.
What happens is most of my bodies will scale correctly, but come to a complete stop when it hits one of the edges, after a short time, it will proceed to bounce away. A few of my bodies will bounce instantly, which is exactly what I would expect. Furthermore, if the collision happens between two bodies, it will bounce instantly.
Any suggestions/solutions will be appreciated, thanks in advance!!