# Not being able to add texture

**URL:** <https://phaser.discourse.group/t/not-being-able-to-add-texture/1997>\
**Category:** Phaser 3\
**Created:** [April 5, 2019, 4:37pm UTC](https://phaser.discourse.group/t/not-being-able-to-add-texture/1997 "2019-04-05T16:37:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![amserra](https://avatars.discourse-cdn.com/v4/letter/a/9de053/32.png) [@amserra](https://phaser.discourse.group/u/amserra)\
**Post date:** [April 5, 2019, 4:37pm UTC](https://phaser.discourse.group/t/not-being-able-to-add-texture/1997/1 "2019-04-05T16:37:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![yannick](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/yannick/32/732_2.png) [@yannick](https://phaser.discourse.group/u/yannick)\
**Post date:** [April 5, 2019, 7:39pm UTC](https://phaser.discourse.group/t/not-being-able-to-add-texture/1997/2 "2019-04-05T19:39:17Z")

</div>

I guess it should be

```javascript
class Sprite extends Phaser.Physics.Arcade.Sprite {
  constructor(scene, xIni, yIni, img) {﻿
    super(scene, xIni, yIni, img)
    scene.add.existing(this)
    scene.physics.add.existing(this)
  }
}

```

---

<div class="post-metadata">

**Author:** ![jjcapellan](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/jjcapellan/32/542_2.png) [@jjcapellan](https://phaser.discourse.group/u/jjcapellan)\
**Post date:** [April 6, 2019, 10:31pm UTC](https://phaser.discourse.group/t/not-being-able-to-add-texture/1997/3 "2019-04-06T22:31:55Z")

</div>

Hi @amserra,  
I also had the same problem extending the class Phaser.Physics.Arcade.Image and my solution was to add the new object from the scene:

```javascript
// In your create() function
player = this.add.existing(new Sprite(this, 200, 200, 'player'));

// In your constructor
scene.physics.world.enable(this);

```

Warning: you couldn’t manipulate the body from the constructor of your Sprite class, since at that moment it still haven’t it.  
Regards.

---

<div class="post-metadata">

**Author:** ![amserra](https://avatars.discourse-cdn.com/v4/letter/a/9de053/32.png) [@amserra](https://phaser.discourse.group/u/amserra)\
**Post date:** [April 9, 2019, 8:13pm UTC](https://phaser.discourse.group/t/not-being-able-to-add-texture/1997/4 "2019-04-09T20:13:26Z")

</div>

Thank you!!
