如何删除 Phaser 3 中的图像?
How to remove an image in Phaser 3?
假设我只是添加了一个简单的小图像:
var image = scene.add.image(200,200,'simple-little-image.png');
然后,我想销毁它。不只是隐藏它,而是删除它的所有数据和所有内容。
我检查了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。
并且查看控制台中的 scene
class,我找不到任何可以删除图像的子函数。
那么,如何删除图像及其所有数据?
虽然它没有 kill()
,但实际上 Image
确实有 destroy()
method。
您可能已经知道,但只要确保您可以访问要销毁它的 image
变量。
假设我只是添加了一个简单的小图像:
var image = scene.add.image(200,200,'simple-little-image.png');
然后,我想销毁它。不只是隐藏它,而是删除它的所有数据和所有内容。
我检查了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。
并且查看控制台中的 scene
class,我找不到任何可以删除图像的子函数。
那么,如何删除图像及其所有数据?
虽然它没有 kill()
,但实际上 Image
确实有 destroy()
method。
您可能已经知道,但只要确保您可以访问要销毁它的 image
变量。