Hi, I want to make my enemy tanks spawn at random points on the canvas, currently I have this code:
for (var i = 0; i < 20; i++)
{
new Enemy(this, Phaser.Math.Between(64, 736, Phaser.Math.Between(100, 500)));
}
however they’re spawning in a symmetrical line. My canvas size is 800 width by 600 height
change to:
new Enemy(this, Phaser.Math.Between(64, 736), Phaser.Math.Between(100, 500));
Thank you, but is there a way I can make them spawn at random places, they’re still spawning roughly close together.
Assuming your second and third parameter are your x and y, the spots should be quite random… Try this instead:
new Enemy(this, Phaser.Math.Between(0, this.game.config.width), Phaser.Math.Between(0, this.game.config.height));
If that is still not working, I’d assume your issue is in your enemy’s constructor.
appreciate your help thank you