4

Let's say I just add a simple little image:

var image = scene.add.image(200,200,'simple-little-image.png');

Then later, I want to destory it. Not just hide it, but remove all of it's data and everything.

I checked the docs and the image class doesn't have any sort of kill or destroy function. However, it has an ignoreDestory boolean. Which makes me think the scene must remove it? But I cannot find a method for removing images in the scene class's docs.

And looking through the scene class in the console, I can't find any functions of it's children that would remove the image.

So, How do I remove the image and all of it's data?

1 Answer 1

9

While it doesn't have a kill(), an Image does in fact have a destroy() method.

You might already be aware, but just make sure you have access to the image variable where you want to destroy it.

1
  • 1
    Also if you want to remove the image from the cache from within the scene this.textures.remove('theKey')
    – Lee
    Jun 7, 2020 at 5:21

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.