Check that image loaded
Taddeus

Hi, one more question about loading images

I am using procedurally generated images and also normal image files in my game. I want to know if there is a way to check if image was loaded before attempting to load it again, and I want to check if image was generated procedurally before trying to generate it again. How can I do that?

1 Comment
Gio
You can use wade.getLoadingStatus(path) to check the loading status of an image. It returns one of the following: 'ok', 'loading', 'error' or undefined.
 
Note that WADE tries to reload images if there are any network errors, it does so automatically up to 10 times. So if an image fails loading once or twice, the status returned by getLoadingStatus will still be 'loading', because WADE will try to load it again automatically. When it fails to download it for 10 times, the status will be 'error'.
 
If you have never requested to load the specified image, calling getLoadingStatus will return undefined.
 
For procedurally generated images (which I assume you are creating with Sprite.drawToImage()), there is no need to check, because they are generated instantly, and calling getLoadingStatus will always return 'ok'.
Post a reply
Add Attachment
Submit Reply
Login to Reply