fixed flake entity issue with shard entity lagging behind

This commit is contained in:
2017-06-04 13:49:03 -05:00
parent c33947ef5f
commit a9443b1acc
3 changed files with 9 additions and 7 deletions

View File

@@ -41,15 +41,17 @@ public class Flake extends Actor implements Poolable, Entity {
@Override
public void act(float delta) {
if (timer > 0) {
timer -= delta;
}
moveBy(rot.x*delta*rate, rot.y*delta*rate);
System.out.println("START");
System.out.println(getY());
for (int i = 0; i < shards.length; i++) {
shards[i].setPosition(getX()+center.x-shards[i].getCenter().x, getY()+center.y-shards[i].getCenter().y);
}
System.out.println(shards[0].getY());
hitbox.setPosition(getX(), getY());
if (getX() > Polyjet.GAME_AREA_WIDTH || getY() > Polyjet.GAME_AREA_HEIGHT || getX() < 0-getWidth() || getY() < 0-getHeight()) {

View File

@@ -61,7 +61,6 @@ public class Shard extends Actor implements Entity, Poolable {
public void act(float delta) {
moveBy(angle.x*delta*rate, angle.y*rate*delta);
hitbox.setPosition(getX(), getY());
sprite.setCenter(getX()+center.x, getY()+center.y);
if (getX() > Polyjet.GAME_AREA_WIDTH || getY() > Polyjet.GAME_AREA_HEIGHT || getX() < 0-getWidth() || getY() < 0-getHeight()) {
hp = 0;
@@ -72,6 +71,8 @@ public class Shard extends Actor implements Entity, Poolable {
@Override
public void draw(Batch batch, float parentAlpha) {
sprite.setCenter(getX()+center.x, getY()+center.y);
sprite.setColor(1f, 0f, (float)hp/(float)maxHp, 1f);
sprite.draw(batch);
batch.setColor(Color.WHITE);