# Sprites no longer placed where I want them to be

**URL:** <https://phaser.discourse.group/t/sprites-no-longer-placed-where-i-want-them-to-be/8965>\
**Category:** Phaser 3\
**Created:** [February 24, 2021, 8:01pm UTC](https://phaser.discourse.group/t/sprites-no-longer-placed-where-i-want-them-to-be/8965 "2021-02-24T20:01:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chair](https://avatars.discourse-cdn.com/v4/letter/c/8e7dd6/32.png) [@Chair](https://phaser.discourse.group/u/Chair)\
**Post date:** [February 24, 2021, 8:01pm UTC](https://phaser.discourse.group/t/sprites-no-longer-placed-where-i-want-them-to-be/8965/1 "2021-02-24T20:01:03Z")

</div>

Hello, I’m creating a Space Invaders style game and I’ve been stuck on this bug for quite a while. When you start the game, it will spawn enemies like this:

 ![bug1](https://global.discourse-cdn.com/free1/uploads/phaser1/original/2X/3/3a480c1cac454d37dcd6c78736e1bd9ab2454f65.png)

The bug occurs when you defeat all of the enemies. The game is supposed to simply respawn new ones in the same pattern, but there is a bug causing them to spawn higher and to the left like this:

 ![bug2](https://global.discourse-cdn.com/free1/uploads/phaser1/original/2X/9/9786504ee17825aadfc7ef9a56ae7f2bdadf5a1b.png)

The enemies are created with a `createEnemies` method:

'createEnemies(){

```
	for(var y = 0; y < 3; y++) {
		for(var x = 0; x < 6; x++) {

				var enemy = this.enemies1.create((1.3*x + 2) * (550 / 7) + 30, ((1.5*y + 2) * 50) - 35, this.getEnemyString(displayed[0]));
				this.enemies.add(enemy); 
				enemy.setScale(.6);
				enemy.flipY = true;
			
			enemy.body.velocity.x = -90
		}
	}
	
	// timer to make enemies change direction
	this.enemyTimer = this.time.addEvent({
		delay: 1500,
		callback: this.changeEnemyDirection,
		callbackScope: this,
		loop: true
	});
}'

```

For the first call to the function (when the enemies are created initially), it is simply called in the `create()` method. When it is called again, it is called in an `enemyReset()` method, where it and many other things are reset.

` enemyReset() {

```
		this.projectiles.clear(true, true);
		this.enemyProjectiles.clear(true, true);
		this.enemies.clear(true, true);
		this.enemies1.clear(true, true);
		this.enemies2.clear(true, true);
		this.enemies3.clear(true, true);
		this.enemies4.clear(true, true);
		this.enemyTimer.remove();
		this.createEnemies();
		
		this.enem_defeated = 0;
		this.defeatedText.text = "Enemies Defeated: " + this.enem_defeated;
}`

```

I can’t seem to figure out what’s wrong because the `createEnemies()` method seems straightforward enough and it’s being placed in a constant value location.

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [February 24, 2021, 9:25pm UTC](https://phaser.discourse.group/t/sprites-no-longer-placed-where-i-want-them-to-be/8965/2 "2021-02-24T21:25:45Z")

</div>

You can try updating Phaser, there was an odd physics bug like this.
