Hello, I have a very strange issue. http://imageshack.com/a/img690/8800/5s8o.png (imageshack seem to be struggling) https://www.dropbox.com/s/uhn738myu60uxox/demonstration.png
package entities.effects.explosions
{
import entities.effects.Explosion;
import net.flashpunk.FP;
import net.flashpunk.graphics.Spritemap;
import net.flashpunk.Entity;
/**
* ...
* @author ...
*/
public class ExplosionAirstrike extends Entity
{
public var sprite:Spritemap;
public var damage:int;
public function ExplosionAirstrike()
{
super();
sprite = new Spritemap(Assets.imgSteamExplosion, 100, 100, destroy);
sprite.add("explode", [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], 12, false);
// sprite.smooth = true;
// sprite.scale = 1.3;
sprite.centerOrigin();
graphic = sprite;
setHitbox(sprite.scaledWidth, sprite.scaledHeight, sprite.scaledWidth / 2, sprite.scaledHeight / 2);
type = "explosion";
layer = -1000;
damage = 150;
}
public function init(posX:int, posY:int):void
{
this.x = posX;
this.y = posY;
sprite.play("explode");
}
private function destroy() :void
{
trace("called");
world.recycle(this);
}
}
}
What happens, if i use world.remove(this), everything works fine. If I, on the other hand, use world.recycle(this), destroy gets called 3-5 times (based on the traces) and I get that strange artefacts you can see on the picture (which are basically what left of the objects because destroy didn’t get called). What am I doing wrong?
I’m spawning this entity like this:
ExplosionAirstrike(world.create(ExplosionAirstrike)).init(200 + strike * 80, 390 + FP.rand(50));