# How To Delete Images On Screen I No Longer Need?

**URL:** <https://phaser.discourse.group/t/how-to-delete-images-on-screen-i-no-longer-need/13183>\
**Category:** Phaser 3\
**Created:** [April 20, 2023, 8:56am UTC](https://phaser.discourse.group/t/how-to-delete-images-on-screen-i-no-longer-need/13183 "2023-04-20T08:56:43Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![JesseLee](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/jesselee/32/7525_2.png) [@JesseLee](https://phaser.discourse.group/u/JesseLee)\
**Post date:** [April 20, 2023, 8:56am UTC](https://phaser.discourse.group/t/how-to-delete-images-on-screen-i-no-longer-need/13183/1 "2023-04-20T08:56:43Z")

</div>

Hi,

Progressing well.

How can I delete images on the screen I no longer need?  
Like when ending a game and returning to the title screen?

Let me know, thanks!

Jesse Lee

> **[Phaser\_Engine by Jesse Lee's Resume & Portfolio](https://jesseleepalser.itch.io/phaser-engine)**
>
> 100% Open-Source Phaser 3 Web Sliding Puzzle Game!

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [April 20, 2023, 12:49pm UTC](https://phaser.discourse.group/t/how-to-delete-images-on-screen-i-no-longer-need/13183/2 "2023-04-20T12:49:23Z")

</div>

You can destroy game objects or (if using multiple scenes) stop the scene they belong to.

---

<div class="post-metadata">

**Author:** ![JesseLee](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/jesselee/32/7525_2.png) [@JesseLee](https://phaser.discourse.group/u/JesseLee)\
**Post date:** [April 20, 2023, 1:05pm UTC](https://phaser.discourse.group/t/how-to-delete-images-on-screen-i-no-longer-need/13183/3 "2023-04-20T13:05:29Z")

</div>

Hi,

Thanks for the reply.  
I am only using one main scene for the entire game.

Would it be possible to have an array of Phaser 3 images?  
Could you provide a small code example to the above idea?

Thanks!

Jesse Lee

```javascript
function LoadAllVisuals ()
{
    this.load.image('sky', 'assets/sky2.png');
    this.load.image('ground', 'assets/platform2.png');
    this.load.image('star', 'assets/star.png');
    this.load.image('bomb', 'assets/bomb.png');
    this.load.spritesheet('dude', 'assets/dude.png', { frameWidth: 32, frameHeight: 48 });

    this.load.image('BG_Screen_Fading', 'data/images/backgrounds/BG_Screen_Fading.png');
    
    this.load.image('GUI_Keyboard', 'data/images/gui/GUI_Keyboard.png');
    this.load.image('GUI_MouseTouch', 'data/images/gui/GUI_MouseTouch.png');

    this.load.image('BG_PHASER_v3_Logo', 'data/images/logos/BG_PHASER_v3_Logo.png');

    this.load.image('BG_JLP', 'data/images/backgrounds/BG_JLP.png');

    this.load.image('BG_Title', 'data/images/backgrounds/BG_Title3.png');

    this.load.image('SPR_Logo', 'data/images/logos/Logo.png');

    this.load.image('SPR_LineOne', 'data/images/gui/Line.png');
    this.load.image('SPR_LineTwo', 'data/images/gui/Line.png');
    this.load.image('SPR_LineThree', 'data/images/gui/Line.png');
    this.load.image('SPR_LineFour', 'data/images/gui/Line.png');
    this.load.image('SPR_LineFive', 'data/images/gui/Line.png');
    this.load.image('SPR_LineSix', 'data/images/gui/Line.png');
    this.load.image('SPR_LineSeven', 'data/images/gui/Line.png');
    this.load.image('SPR_LineEight', 'data/images/gui/Line.png');
    this.load.image('SPR_LineNine', 'data/images/gui/Line.png');
    this.load.image('SPR_LineTen', 'data/images/gui/Line.png');

}

```

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [April 20, 2023, 2:23pm UTC](https://phaser.discourse.group/t/how-to-delete-images-on-screen-i-no-longer-need/13183/4 "2023-04-20T14:23:42Z")

</div>

```js
player.destroy();
stars.destroy();

```

You’ll be destroying game objects, not textures (assets).

If you intend to recreate the game objects later, you will probably want to move to a 2-scene pattern, where all you need to do is restart the scene.

---

<div class="post-metadata">

**Author:** ![JesseLee](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/jesselee/32/7525_2.png) [@JesseLee](https://phaser.discourse.group/u/JesseLee)\
**Post date:** [April 20, 2023, 2:24pm UTC](https://phaser.discourse.group/t/how-to-delete-images-on-screen-i-no-longer-need/13183/5 "2023-04-20T14:24:35Z")

</div>

Ok, thanks - I’ll try that!

---

<div class="post-metadata">

**Author:** ![JesseLee](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/jesselee/32/7525_2.png) [@JesseLee](https://phaser.discourse.group/u/JesseLee)\
**Post date:** [April 20, 2023, 3:15pm UTC](https://phaser.discourse.group/t/how-to-delete-images-on-screen-i-no-longer-need/13183/6 "2023-04-20T15:15:17Z")

</div>

Sorry:

Is it technically possible to have an array of images?  
Image management would be much simpler if I could have an array.  
Let me know, thanks!

Jesse Lee

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [April 20, 2023, 4:12pm UTC](https://phaser.discourse.group/t/how-to-delete-images-on-screen-i-no-longer-need/13183/7 "2023-04-20T16:12:34Z")

</div>

You can make an array of game objects, yes.

---

<div class="post-metadata">

**Author:** ![JesseLee](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/jesselee/32/7525_2.png) [@JesseLee](https://phaser.discourse.group/u/JesseLee)\
**Post date:** [April 20, 2023, 4:33pm UTC](https://phaser.discourse.group/t/how-to-delete-images-on-screen-i-no-longer-need/13183/8 "2023-04-20T16:33:57Z")

</div>

Thanks, got it working now:

```javascript
var SPR_LineDivider = [10];

    for (index = 0; index < 10; index++)
    {
        SPR_LineDivider[index] = this.load.image('SPR_LineDivider[index]', 'data/images/gui/Line.png');
    }

    for (index = 0; index < 10; index++)
    {
        SPR_LineDivider[index] = this.add.image(-99999, -99999, 'SPR_LineDivider[index]');
        SPR_LineDivider[index].setDepth(1);
        DrawSprite(SPR_LineDivider[index], 320, 180, 1.0, 1.0, 0, 255, 255, 255, 0);
    }

DrawSprite(SPR_LineDivider[0], 320, 92, 1.0, 1.0, 0, 255, 255, 255, 255);

```

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [April 20, 2023, 4:51pm UTC](https://phaser.discourse.group/t/how-to-delete-images-on-screen-i-no-longer-need/13183/9 "2023-04-20T16:51:48Z")

</div>

Not from `load.image()`, it doesn’t create or return a game object. And the loop after that is overwriting `SPR_LineDivider[0]` etc. anyway.

```js
var SPR_LineDivider = [];

for (index = 0; index < 10; index++) {
  SPR_LineDivider[index] = this.add.image(0, 0, "line");
}

```

---

<div class="post-metadata">

**Author:** ![JesseLee](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/jesselee/32/7525_2.png) [@JesseLee](https://phaser.discourse.group/u/JesseLee)\
**Post date:** [April 20, 2023, 5:05pm UTC](https://phaser.discourse.group/t/how-to-delete-images-on-screen-i-no-longer-need/13183/10 "2023-04-20T17:05:18Z")

</div>

Ok, I will fix that, thanks!
