class Enemy extends Phaser.Physics.Arcade.Sprite {
aTurret
constructor(scene, x, y, texture) {
super(scene, x, y, texture = 'enemy', 'tank1')
scene.add.existing(this)
scene.physics.add.existing(this)
scene.events.on('update', this.update, this)
this.setVelocity(100, 0);
this.setCollideWorldBounds(true);
this.body.bounce.setTo(1, 1);
this.body.immovable = false;
this.health = 3;
this.alive = true;
this.aTurret = new aTurret(scene)
}
update() {
this.aTurret.follow(this)
}
}
class aTurret extends Phaser.GameObjects.Sprite {
constructor(scene, x, y, texture = ‘turret’){
super(scene, x, y, texture)
scene.add.existing(this)
}
follow(demon) {
this.setX(demon.x)
this.setY(demon.y)
}
}
create() {
let demon = new Enemy(this, 100, 100);
demons = this.physics.add.group();
for (var i = 0; i < 20; i++)
{
var pos = demons.create(new Enemy);
this.physics.add.existing(pos);
}
}
I keep getting error “sys” of undefined and cannot seem to figure it out. The above code is causing this error but I do not know why!