Problem with static body

Discuss issues specific to using Box2D on the iPhone
Posts: 1
Joined: Wed May 14, 2014 12:42 pm

Problem with static body

Postby sebber » Wed May 14, 2014 12:48 pm

I am working on a small game that allows you to shoot a ball in a certain direction. The ball has to collide with a static body, and it does it just seems like the static body is trying to hide. The UIView shows up where I have placed it, but when I shoot the ball in that direction it collides with something invisible. Have I set the position using a wrong method?

Code: Select all

-(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;

Help much appreciated!

Return to “iPhone”

Who is online

Users browsing this forum: No registered users and 1 guest