alex_h Posted August 8, 2013 Share Posted August 8, 2013 I have a couple of questions regarding image asset management. Most if not all of my image assets tend to be held in large 32bit .png format texture atlases, the file sizes of which can be up to about a meg. When preloading these, is there way to poll for the load progress of an individual image file? Currently I just wait for each to finish loading and then tween my load bar along a predetermined percentage, which is ok, but not really ideal! My other question is about unloading images. I'm working on a game with several levels and I'd like each of them to have different parallax backgrounds. So think I'd better load and unload images between levels to avoid hitting memory limits on lower spec devices. I've not tried unloading images in javascript previously, presumably it is as simple as removing all references to the image element to free it up for garbage collection? Or is there some more specific trick to it that I don't yet know about? cheers,Alex Quote Link to comment Share on other sites More sharing options...
rich Posted August 8, 2013 Share Posted August 8, 2013 You can't get the load progress of an image unless you load it via xhr2, which isn't supported on lots of older browsers. Equally unloading them is just as hard You can null off all of your Image() references, but there's no guarantee they will actually be removed from memory at all. From what I've observed they tend to stick around regardless. Quote Link to comment Share on other sites More sharing options...
alex_h Posted August 9, 2013 Author Share Posted August 9, 2013 thanks for the infos... not good news then really on the unloading front! I'll have a look at loading images via xhr2 though, I can probably get away with ignoring most of the older browsers going on what I've seen on http://caniuse.com/xhr2 cheers,Alex Quote Link to comment Share on other sites More sharing options...
narushevich Posted August 17, 2013 Share Posted August 17, 2013 Once you've nulled all references to image and if device is short on memory , in that case I guess you can be sure that GC will delete your image from memory)I've made some simple asset manager for my own purposes based on XHR2, you can take a look on sources here. https://bitbucket.org/narushevich/scalia-no3d/src/839c96dfb5017f719c0bedac7b5a96134a1891d1/engine/AssetManager.js?at=default Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.