使用此属性:
b2FixtureDef ballShapeDef;
ballShapeDef.shape = &circle;
ballShapeDef.density = 1.0f;
ballBodyDef.linearDamping = 1.0f;
ballBodyDef.bullet = YES;
ballShapeDef.friction = 1.0f;
ballShapeDef.restitution = 0.7f;
ballBodyDef.angularDamping = 3;
我试图在设置为重力(0,0)的世界中模拟一个台球并像这样击球:
- (void) applyShot:(float) ang {
float vx = 10 * cosf(ang);
float vy = 10 * sinf(ang);
b2Vec2 velVec = _whiteBall->GetLinearVelocity();
velVec.x += (vx * 10);
velVec.y += (vy * 10);
_whiteBall->SetLinearVelocity(velVec);
}
球的表现确实有点不切实际,因为它在击球后在台面上“滑”得太慢了,没有停下来。
我的桌子边框是静态墙,够了吗?
问候米尔扎