Add dispose() to Entity and implement in Brick

This commit is contained in:
Matt Low 2018-11-15 23:14:45 +04:00
parent e116f1064d
commit 9df81ee854
2 changed files with 9 additions and 2 deletions

View File

@ -27,6 +27,7 @@ public class Brick extends Entity implements PhysicsBody, CollisionListener {
public static final float BRICK_HEIGHT = 2.5f; public static final float BRICK_HEIGHT = 2.5f;
private static final EarClippingTriangulator ECT = new EarClippingTriangulator(); private static final EarClippingTriangulator ECT = new EarClippingTriangulator();
private static final Vector2 tmp = new Vector2();
private BrickType type; private BrickType type;
private BrickShape shape; private BrickShape shape;
@ -40,8 +41,6 @@ public class Brick extends Entity implements PhysicsBody, CollisionListener {
private Body body; private Body body;
private boolean hitByBall = false; private boolean hitByBall = false;
private final Vector2 tmp = new Vector2();
public Brick(PlayState state, PowerUpType powerUpType, float x, float y) { public Brick(PlayState state, PowerUpType powerUpType, float x, float y) {
this(state, powerUpType, true, x, y); this(state, powerUpType, true, x, y);
} }
@ -209,6 +208,12 @@ public class Brick extends Entity implements PhysicsBody, CollisionListener {
public void endContact(Entity contacted) { public void endContact(Entity contacted) {
} }
@Override
public void dispose() {
solid.dispose();
pm.dispose();
}
public boolean hit() { public boolean hit() {
if (state.bricks.size-1 <= Ball.BLOCKS_FOR_BOOST) { if (state.bricks.size-1 <= Ball.BLOCKS_FOR_BOOST) {
for (Ball ball : state.balls) { for (Ball ball : state.balls) {

View File

@ -23,6 +23,8 @@ public abstract class Entity {
public abstract void update(float dt); public abstract void update(float dt);
public void dispose() {}
public Vector2 getPos() { public Vector2 getPos() {
return pos; return pos;
} }