When I set a hitbox to my Bird entity, it is removed after 1 update. Whether it’s a hitbox or a pixelmask, the same thing happens. I put some trace code into the constructor and update function, and based on its position I know that it’s updating once before being deleted.
I’m certain it’s not colliding with anything because I don’t have any collision functions. I’ve commented out the only one I’ve made.
I’m not sure how to debug this.
public class Bird extends Entity { [Embed(source = ‘…/assets/graphics/birdRed.png’)] private const BIRD_GRAPHIC:Class; [Embed(source = ‘…/assets/graphics/birdMask.png’)] private const BIRD_MASK:Class; protected var birdAnim:Spritemap;
public function Bird()
{
birdAnim = new Spritemap(BIRD_GRAPHIC, 39, 36);
birdAnim.add("fly right", [0, 1, 2, 3], 8);
birdAnim.add("fly left", [4, 5, 6, 7], 8);
this.graphic = birdAnim;
birdAnim.play("fly right");
this.x = 10;
this.y = 50;
this.layer = 6;
this.type = "bird";
//mask = new Pixelmask(BIRD_MASK);
trace("bird");
}
public function Die():void
{
SpawnController.birdCount -= 1;
FP.world.remove(this);
}
override public function update():void
{
trace("bird updated");
this.x += 100 * FP.elapsed;
if (this.x > 800 + width || 0 - width)
{
Die();
}
}
}
Here is the game without the pixelmask
I really have no idea how to begin solving this. It’s not being deleted because of a collision, because there aren’t any collision checks.