diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/EyeSprite.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/EyeSprite.java index c9053e41f..5791a1252 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/EyeSprite.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/EyeSprite.java @@ -50,11 +50,6 @@ public class EyeSprite extends MobSprite { charging = new Animation( 12, true); charging.frames( frames, 3, 4 ); - - chargeParticles = centerEmitter(); - chargeParticles.autoKill = false; - chargeParticles.pour(MagicMissile.MagicParticle.ATTRACTING, 0.05f); - chargeParticles.on = false; run = new Animation( 12, true ); run.frames( frames, 5, 6 ); @@ -72,14 +67,38 @@ public class EyeSprite extends MobSprite { @Override public void link(Char ch) { super.link(ch); + + chargeParticles = centerEmitter(); + chargeParticles.autoKill = false; + chargeParticles.pour(MagicMissile.MagicParticle.ATTRACTING, 0.05f); + chargeParticles.on = false; + if (((Eye)ch).beamCharged) play(charging); } @Override public void update() { super.update(); - chargeParticles.pos(center()); - chargeParticles.visible = visible; + if (chargeParticles != null){ + chargeParticles.pos( center() ); + chargeParticles.visible = visible; + } + } + + @Override + public void die() { + super.die(); + if (chargeParticles != null){ + chargeParticles.on = false; + } + } + + @Override + public void kill() { + super.kill(); + if (chargeParticles != null){ + chargeParticles.killAndErase(); + } } public void charge( int pos ){ @@ -89,7 +108,7 @@ public class EyeSprite extends MobSprite { @Override public void play(Animation anim) { - chargeParticles.on = anim == charging; + if (chargeParticles != null) chargeParticles.on = anim == charging; super.play(anim); }