# This.add.image is not a function Phaser 3.16

**URL:** <https://phaser.discourse.group/t/this-add-image-is-not-a-function-phaser-3-16/7044>\
**Category:** Phaser 3\
**Created:** [July 29, 2020, 8:25pm UTC](https://phaser.discourse.group/t/this-add-image-is-not-a-function-phaser-3-16/7044 "2020-07-29T20:25:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![wattsjmichael](https://avatars.discourse-cdn.com/v4/letter/w/96bed5/32.png) [@wattsjmichael](https://phaser.discourse.group/u/wattsjmichael)\
**Post date:** [July 29, 2020, 8:25pm UTC](https://phaser.discourse.group/t/this-add-image-is-not-a-function-phaser-3-16/7044/1 "2020-07-29T20:25:25Z")

</div>

Hello,

I working with the Zenva Tutorials and I have ran into an issue.

```javascript
class UiButton extends Phaser.GameObjects.Container {
    constructor(scene, x, y, key, hoverKey, text, targetCallback){
        super(scene, x, y);
        this.scene = scene; // the scene this container will be added to
        this.x = x; // x pos
        this.y = y; // y pos
        this.key = key; // BG image of button
        this.hoverKey = hoverKey; // image displays when hovered
        this.text = text; // text displayed on button
        this.targetCallback = targetCallback; // the callback function that will be called when clicked
    
        this.createButton(); // Creates UI Button
        this.scene.add.existing(this); // adds this container to our Phaser Scene
    }

    createButton() {
        //create Play Game Button
        this.button = this.add.image(0, 0, "button1");
        //make button interactive
        this.button.setInteractive();

        //scale the button
        this.button.setScale(1.4);

        //create button text
        this.buttonText = this.add.text(0, 0, this.text, {fontSize: "26px", fill: "#fff"});
        //center text in ui button
        Phaser.Display.Align.In.Center(this.buttonText, this.button);

        //add the two game objects to container
        this.add(this.button);
        this.add(this.buttonText);

        //Listen for events
        this.button.on("pointerdown", () => {
            this.targetCallback();
        });

        this.button.on("pointerover", () => {
            this.button.setTexture(this.hoverKey);
        });
        
        this.button.on("pointerout", () => {
            this.button.setTexture(this.key);
        });
        

    }
}

```

Any help would be appreciated!

Cheers

---

<div class="post-metadata">

**Author:** ![BlunT76](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/blunt76/32/1454_2.png) [@BlunT76](https://phaser.discourse.group/u/BlunT76)\
**Post date:** [July 29, 2020, 8:56pm UTC](https://phaser.discourse.group/t/this-add-image-is-not-a-function-phaser-3-16/7044/2 "2020-07-29T20:56:17Z")

</div>

Hi  
Phaser 3.16 is old 😕  
Try this.scene.add.image

---

<div class="post-metadata">

**Author:** ![wattsjmichael](https://avatars.discourse-cdn.com/v4/letter/w/96bed5/32.png) [@wattsjmichael](https://phaser.discourse.group/u/wattsjmichael)\
**Post date:** [July 29, 2020, 9:13pm UTC](https://phaser.discourse.group/t/this-add-image-is-not-a-function-phaser-3-16/7044/3 "2020-07-29T21:13:30Z")

</div>

I know 3.16 is old, but it was the one that was used in the tutorial.

Also, that WORKED!

Is that because I had this.scene.add.existing(this) in my constructor?

Thanks again!

---

<div class="post-metadata">

**Author:** ![BlunT76](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/blunt76/32/1454_2.png) [@BlunT76](https://phaser.discourse.group/u/BlunT76)\
**Post date:** [July 29, 2020, 9:42pm UTC](https://phaser.discourse.group/t/this-add-image-is-not-a-function-phaser-3-16/7044/4 "2020-07-29T21:42:02Z")

</div>

No, your UIbutton extends a container, and this.scene.add.existing(this) add this container to the scene

---

<div class="post-metadata">

**Author:** ![Sansabear](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/sansabear/32/3849_2.png) [@Sansabear](https://phaser.discourse.group/u/Sansabear)\
**Post date:** [August 10, 2020, 11:25am UTC](https://phaser.discourse.group/t/this-add-image-is-not-a-function-phaser-3-16/7044/5 "2020-08-10T11:25:52Z")

</div>

I ran into the same problem and wanted to add that this question has to do with a Zenva course called “Intro to RPG Development with Phaser”, lesson 15. The video was partially outdated. After finding the solution here (thank you BluntT76!) I realized that there was also an update in the course lesson notes at Zenva, but it was not obvious that there were any notes there.
