amserra Posted March 29, 2019 Share Posted March 29, 2019 I 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.