Jump to content

Image asset management


alex_h
 Share

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 2 weeks later...

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

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...