Closed taoabc closed 5 years ago
@jcyuan
👍 good catch, a potential bug of memory leak.
but we can just use image.addToCache();
instead.
the old code should be a legacy problem made when immigrating to the new db file plugin.
I don't recommend add this image to cache because we already add image to textureManager, will become more heavier. What do you think? :grin:
image.addToCache
, this action actually does 2 things:
1, add the loaded image into the textureManager
belongs to the loader
. (global to scene)
2, call pendingDestroy
to prepare to delete the stuffs created when loading the images
only a diffenent between them is, addToCache
detects to see if the image to be loaded has a normal map or not, if it does, add to cache too.
so actually they are the same, but use Phaser's API is more sensible because you don't knwo whether they will be changed in the furture or not, right?
You're right, I've changed to addToCache
Sorry for misunderstand your suggest, fixed and refresh output files at newest commit.
thanks for your effort @taoabc 👍
Call json.addToCache will call pendingDestroy internally, but add image to textureManager will not, so I call pendingDestroy manually.