Skip to content

Commit

Permalink
🐛 fix box2d positioning issue
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbrain committed Nov 29, 2019
1 parent 0b391fb commit 4b01fba
Show file tree
Hide file tree
Showing 4 changed files with 387 additions and 372 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ public class PhysicsBodyFactory {

public static PolygonShape getRectangle(Rectangle rectangle) {
PolygonShape polygon = new PolygonShape();
Vector2 size = new Vector2((rectangle.x + rectangle.width * 0.5f),
(rectangle.y + rectangle.height * 0.5f));
polygon.setAsBox(rectangle.width * 0.5f,
rectangle.height * 0.5f,
size,
new Vector2(rectangle.width * 0.5f, rectangle.height * 0.5f),
0.0f);
return polygon;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ private void handlePhysicsObject(MapObject mapObject, MapProperties objectProper
}
BodyDef bd = new BodyDef();
bd.position.set(objectProperties.get(Constants.X, 0f, Float.class), objectProperties.get(Constants.Y, 0f, Float.class));

bd.type = BodyDef.BodyType.StaticBody;
Body body = physicsManager.getPhysicsWorld().createBody(bd);
for (Shape shape : shapes) {
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Version 0.6.9

* fixed a positioning issue when centering rectangular box2d objects

# Version 0.6.8

* [[#130](https://github.com/bitbrain/braingdx/issues/130)] introduce box2d support for tiled
Expand Down
Loading

0 comments on commit 4b01fba

Please sign in to comment.