export class AdEnemy {
constructor(scene, x, y, label, color = 0xff004d) {
this.scene = scene;
this.sprite = scene.add.container(x, y);
this.box = scene.add.rectangle(0, 0, 96, 42, color, 0.96);
this.text = scene.add.text(0, 0, label, {
fontFamily: 'system-ui, sans-serif',
fontSize: '12px',
color: '#ffffff',
fontStyle: '700',
align: 'center',
wordWrap: { width: 84 },
}).setOrigin(0.5);
this.sprite.add([this.box, this.text]);
scene.physics.add.existing(this.sprite);
this.sprite.body.setSize(96, 42);
this.sprite.body.setOffset(-48, -21);
this.sprite.body.allowGravity = false;
this.sprite.body.setVelocityX(-80 - Math.random() * 90);
}
update(time) {
this.sprite.y += Math.sin(time / 220 + this.sprite.x * 0.01) * 0.25;
if (this.sprite.x < this.scene.cameras.main.scrollX - 160) {
this.sprite.destroy();
}
}
}