Hi, I have this class constructor and I’m trying to spawn enemies onto my canvas however they are not showing up? There is not error either… Help would be greatly appreciated
class Enemy extends Phaser.Physics.Arcade.Sprite {
constructor(scene, game, tank, player, x, y, bullets){
super(scene);
var x = Phaser.Math.RND.between(0, 800);
var y = Phaser.Math.RND.between(0, 600);
this.game = game;
//scene.physics.add.existing(this)
this.health = 3;
this.player = player;
this.bullets = bullets;
this.fireRate = 1000;
this.nextFire = 0;
this.alive = true;
this.turret = new Phaser.Physics.Arcade.Sprite(scene, 100, 100, 'enemy', 'tank1');
this.tank = new Phaser.Physics.Arcade.Sprite(scene, 100, 100, 'enemy', 'turret');
this.turret.setOrigin(0.3, 0.5);
this.tank.setOrigin(0.5, 0.5);
/*this.tank.body.immovable = false;
this.tank.body.collideWorldBounds = true;
this.tank.body.bounce.setTo(1, 1);*/
}
update(time, delta) {
this.turret.x = this.tank.x;
this.turret.y = this.tank.y;
}
}
myguy = this.physics.add.group({
classType: Enemy,
maxSize: 20,
runChildUpdate: true
});
myguyy = myguy.get().setActive(true).setVisible(true);