我有一些盒子,使用box2d創建,其恢復原狀設置爲零。但是當它們相互墜落時,會出現反彈事件。但我不想那樣...我想要如果我關掉gravity.but我也想gravity.here是我的代碼它們不動的時候爭先恐後another.it可以做到box2d:在碰撞時禁用反彈
UIImage *imageOfSnowV1 = [ UIImage imageNamed:[NSString stringWithFormat:@"Object%d.png",currentlySelected]];
CCTexture2D *texOfSnowV1 = [[ [CCTexture2D alloc] initWithImage:imageOfSnowV1 ] autorelease];
CCSprite *sprite = [CCSprite spriteWithTexture:texOfSnowV1 rect:CGRectMake(0, 0, 32, 32)];
[self addChild:sprite];
sprite.position = ccp(p.x, p.y);
sprite.tag=[temp intValue];
// Define the dynamic body.
//Set up a 1m squared box in the physics world
b2BodyDef bodyDef;
bodyDef.type = b2_dynamicBody;
bodyDef.position.Set(p.x/PTM_RATIO, p.y/PTM_RATIO);
bodyDef.userData = sprite;
b2Body *bodyS = world->CreateBody(&bodyDef);
// Define another box shape for our dynamic body.
b2PolygonShape dynamicBox;
dynamicBox.SetAsBox(.5f, .5f);//These are mid points for our 1m box
b2MassData massData;
massData.mass = 0.1f;
bodyS->SetMassData(&massData);
// Define the dynamic body fixture.
b2FixtureDef fixtureDef;
fixtureDef.shape = &dynamicBox;
fixtureDef.density = 50.0f;
fixtureDef.restitution=0.0f;
fixtureDef.friction = 0.01f;
bodyS->CreateFixture(&fixtureDef);
誰能幫助我?
@剋日什托夫·Zabłocki:我也嘗試that..already修改內聯函數....但沒有運氣 – Rony 2010-10-06 09:00:01
也許在你的碰撞委託設置爲睡眠動態對象?這是一個黑客,但可能工作。 – 2010-10-06 12:37:22
哈哈哈......似乎每一個想在同樣的方式......也試過這個.. – Rony 2010-10-06 13:25:18