Skip to content

Commit

Permalink
remove body from box2d
Browse files Browse the repository at this point in the history
  • Loading branch information
feroult committed Jul 20, 2018
1 parent 435516d commit 443f304
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lib/box2d/box2d_component.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ abstract class Box2DComponent extends Component {
int positionIterations;

World world;
List<Component> components = [];
List<BodyComponent> components = [];
Viewport viewport;

Box2DComponent({
Expand Down Expand Up @@ -51,7 +51,9 @@ abstract class Box2DComponent extends Component {
return;
}
components.forEach((c) {
c.render(canvas);
if (c.body.isActive()) {
c.render(canvas);
}
});
}

Expand All @@ -63,14 +65,19 @@ abstract class Box2DComponent extends Component {
});
}

void add(Component component) {
void add(BodyComponent component) {
components.add(component);
}

void addAll(List<Component> component) {
void addAll(List<BodyComponent> component) {
components.addAll(component);
}

void remove(BodyComponent component) {
components.remove(component);
world.destroyBody(component.body);
}

void initializeWorld();

void cameraFollow(
Expand Down

0 comments on commit 443f304

Please sign in to comment.