However, once adding a static body to the shape, it has a correct x position but the y position is moved 50 up from where I put in the value. And upon adding a second static body inside the space it has a messed up x and y position, so there doesn't seem to be any rhyme or reason to it. Can anyone help me figure out why this would be doing what its doing?
Code for space:
Code: Select all
world = [[ChipmunkSpace alloc] init]; // Create the space
[world addBounds:CGRectMake(-25, -25, self.view.bounds.size.width, self.view.bounds.size.height)
thickness:10.0f
elasticity:1.0f
friction:1.0f
layers:CP_ALL_LAYERS
group:CP_NO_GROUP
collisionType:@"border"];
Code: Select all
_body = [ChipmunkBody staticBody]; // Creates a static body
_body.pos = cpv(rect.origin.x, rect.origin.y + 50); // <- The +50 corrects the first displacement
ChipmunkShape *shape = [ChipmunkPolyShape boxWithBody:_body width:rect.size.width height:rect.size.height]; // Creates the shape
shape.friction = 1.0f;
shape.elasticity = 1.0f;
[view addSubview:_view];
[space addStaticShape:shape];