Use instance bodies array

This commit is contained in:
Matt Low 2018-11-15 14:48:32 +04:00
parent adebc42c16
commit 9eac3353b6

View File

@ -61,6 +61,8 @@ public class PlayState extends State {
// Initialize a world with no gravity
world = new World(new Vector2(), false);
world.setContactListener(new Box2dContactListener());
bodies = new Array<Body>();
// define a playArea body with position set to 0
BodyDef playAreaDef = new BodyDef();
@ -117,7 +119,6 @@ public class PlayState extends State {
@Override
public void render() {
Array<Body> bodies = new Array<Body>();
world.getBodies(bodies);
for (Body b : bodies) {
Entity e = (Entity) b.getUserData();
@ -207,9 +208,10 @@ public class PlayState extends State {
@Override
public void dispose() {
super.dispose();
world.dispose();
bodies.clear();
powerUps.clear();
powerUps = null;
balls.clear();