Box2D Forums

It is currently Fri May 24, 2013 3:35 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Sun Jan 16, 2011 3:46 pm 
Offline

Joined: Sun Jan 16, 2011 3:29 pm
Posts: 1
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#p26070



I 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!!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group