Jump to content

Not being able to add texture


Recommended Posts

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);





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

Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...