Sprite Failure to Load Image Callback?

Discussion and feedback on Construct 2

Post » Tue May 13, 2014 8:34 pm

I have several hundred images included with the package as project files. For whatever reason, some of them are intermittently failing to load. Sometimes they work and sometimes they don't.

My workaround is to try to reload the image if the image load fails.

Is it possible to get a callback when an image fails to load from URL? I would like the system to automatically try to load the image again, rather than requiring some user input if the image doesn't appear. I tried to detect failure based on the size of the image (set size to 0,0, load image and resize to image size, then detect if the size is still 0,0 -> if so, then image failed to load), but my technique didn't work.

Any ideas?
www.simbucket.com - HTML5 Science Simulations / https://www.airconsole.com/#!play=com.n ... obotrumble - Robot Rumble on AirConsole
B
45
S
11
G
20
Posts: 363
Reputation: 14,174

Post » Tue May 13, 2014 9:08 pm

Update: I was able to detect when the image doesn't load by detecting when the image height = infinity (>100000).

The problem now is that the image will always load the first time, but if I later try to load the same image, all subsequent reloads of that image will fail until I leave the layout, load a different image, then go back to the layout and try again with the first image.

imageloadingeventsheet.PNG


The same problem occurs whether I am working on a desktop or an ipad.
You do not have the required permissions to view the files attached to this post.
www.simbucket.com - HTML5 Science Simulations / https://www.airconsole.com/#!play=com.n ... obotrumble - Robot Rumble on AirConsole
B
45
S
11
G
20
Posts: 363
Reputation: 14,174

Post » Wed May 14, 2014 3:24 pm

Problem solved with the following workaround:

1. Load a dummy image first.
2. Next, load the desired image.

This seems to work consistently. I still have no idea why I can't consecutively load the same image into a sprite.
www.simbucket.com - HTML5 Science Simulations / https://www.airconsole.com/#!play=com.n ... obotrumble - Robot Rumble on AirConsole
B
45
S
11
G
20
Posts: 363
Reputation: 14,174


Return to Construct 2 General

Who is online

Users browsing this forum: Colludium and 6 guests