我正在制作一款允许你向某个方向射球的小型比赛。球必须与静止的身体碰撞,它看起来就像静态的身体试图隐藏。 UIView
显示我放置它的位置,但是当我朝那个方向射球时,它会与看不见的东西碰撞。我是否使用错误的方法设置了位置?
-(void)createBoxWithView:(UIView *)physicalView{
b2BodyDef bd;
bd.type = b2_staticBody;
bd.userData = (__bridge void*)physicalView;
CGPoint center = [physicalView center];
bd.position.Set(center.x/PTM_RATIO, (self.view.frame.size.width - center.y)/PTM_RATIO);
b2Body *body = world->CreateBody(&bd);
b2PolygonShape box;
box.SetAsBox(10/PTM_RATIO, 10/PTM_RATIO);
b2FixtureDef fd;
fd.shape = &box;
body->SetType(b2_staticBody);
body->CreateFixture(&fd);
}
非常感谢! 谢谢!