Hello,
I am being thrown and error that an object I’m trying to create within a scene is not defined.
I have created this object in a separate .js – I’m copying another set of code that works so I’m not sure what I’m missing.
In my main scene I have:
createEnemies() {
this.enemies = this.physics.add.group()
//this.enemies.enableBody = true
var snake = new Enemy1(this, 15,385);
}
and in a separate .js
I have:
class Enemy1 extends Phaser.GameObjects.Sprite{
constructor(scene, x, y){
x *= 16;
y *= 16;
super(scene, x, y);
scene.add.existing(this);
scene.enemies.add(this);
}
but console is throwing me an Enemy1 is not defined. I have also already loaded the .js in the HTML doc.
Is there any other reason I’m being given this error?
EDIT: I’m sorry, I fixed it, I forgot a } to close off the class.