am trying to build a ES6 class to modularize my project. I had this working file:
player = this.physics.add.sprite(200, 200, ‘player’);
And so far I was able to replace it on create() like this:
player = new Sprite(this, 200, 200, ‘player’);
With the sprite class being:
class Sprite extends Phaser.Physics.Arcade.Sprite {
constructor(scene, xIni, yIni, img) {
super(scene, xIni, yIni, img);
scene.physics.add.existing(this);
}
}
Everything is working fine(collisions, intersections, etc.), however the texture is not appearing. It’s sort of transparent, I can move the object, but the image doesn’t appear.
I have already tried to add this.setTexture(‘player’); on the constructor, however it didn’t work either.
I preload my player like this in the preload() function: this.load.atlas(‘player’, ‘/Resources/player.png’, ‘/Resources/player.json’);
Thank you