Fix the original vanish effect never disappearing

This commit is contained in:
Lonami Exo 2017-07-08 21:35:41 +02:00
parent ccec6f7b81
commit 79fac8c328

View file

@ -43,23 +43,20 @@ public class VanishEffect implements IEffect {
@Override @Override
public void draw(SpriteBatch batch) { public void draw(SpriteBatch batch) {
// Draw the previous vanishing cell vanishElapsed += Gdx.graphics.getDeltaTime();
if (vanishElapsed <= vanishLifetime) {
vanishElapsed += Gdx.graphics.getDeltaTime();
// vanishElapsed might be < 0 (delay), so clamp to 0 // vanishElapsed might be < 0 (delay), so clamp to 0
float progress = Math.min(1f, float progress = Math.min(1f,
Math.max(vanishElapsed, 0f) / vanishLifetime); Math.max(vanishElapsed, 0f) / vanishLifetime);
vanishSize = Interpolation.elasticIn.apply(cell.size, 0, progress); vanishSize = Interpolation.elasticIn.apply(cell.size, 0, progress);
float centerOffset = cell.size * 0.5f - vanishSize * 0.5f; float centerOffset = cell.size * 0.5f - vanishSize * 0.5f;
Cell.draw(vanishColor, batch, cell.pos.x + centerOffset, cell.pos.y + centerOffset, vanishSize); Cell.draw(vanishColor, batch, cell.pos.x + centerOffset, cell.pos.y + centerOffset, vanishSize);
}
} }
@Override @Override
public boolean isDone() { public boolean isDone() {
return false; return vanishElapsed > vanishElapsed;
} }
} }