0
여기에 타입 변환 문제가 있으며 전체 시간 동안 머리를 부러 뜨 렸습니다. 문제는 ApplyForce 함수에 있습니다. 우리는 b2Vec2 (중력)에 float (질량)을 곱할 수 없습니다. 나는 예를 따랐다 here 누군가 나를 도울 수 있습니까? 형 b2Body *의 CannonBallBody으로Box2D 타입 변환 : ApplyForce() 반 중력
-(void) antiGravity
{
float32 total_mass = [cannonBallBody getMass];
b2Vec2 point0 = [cannonBallBody getWorldCenter: cannonBallBody];
cannonBallBody -> ApplyForce(-1 * world -> GetGravity() * total_mass, cannonBallBody -> GetWorldCenter());
}
과
- (float) getMass{
float total_mass = 0;
for(int i=0; i<8; i++){
total_mass+= body1[i]-> GetMass();
}
return total_mass;
}
- (b2Vec2) getWorldCenter: (b2Body*)body{
return body->GetWorldCenter();
}
감사합니다!