Hi, I have created a constructor class for my Healthbar which looks as follows:
class HealthBar extends Phaser.GameObjects.Image {
constructor(scene, x, y) {
super(scene, x, y);
scene.add.existing(this);
this.scene.add.rectangle(x, y, 60, 10, 0xFFFF00).setStrokeStyle(2, 0x000000);
}
}
Everything works fine as for now however when I call it into my Enemy class constructor the rectangle is leaving a mark every time the enemy tank moves. (the tank object has a set velocity) Here is a screenshot:
This is how I have called it into my Enemy class constructor:
let healthy = new HealthBar(this.scene, this.enemy.x, this.enemy.y);
Does anybody seem to know why it is leaving a mark?