YouTube

Got a YouTube account?

New: enable viewer-created translations and captions on your YouTube channel!

English subtitles

← Caching images - HTML5 Game Development

Get Embed Code
4 Languages

Showing Revision 6 created 05/24/2016 by Udacity Robot.

  1. Hi, welcome back to the show. Let's take a look at the solution here. So, our

  2. loadAsset function should first check the gCachedAssets dictionary for the file
  3. name that was provided if the file is not present in the cache, then the result
  4. of this access will return no. If this happens we know that the image has been
  5. loaded, and we need to actually issue a load call. From here we can actually
  6. create our image do our on load, and set our source. Once is all done we
  7. actually set the image object as the value to the key of asset name inside of
  8. the cache. This allows us later, once again, to go through, query for a name
  9. and get an object, which you can see down here. If the object has already been
  10. loaded, then when we query for it, we'll get a something back, which allows us
  11. to pass that image object to the callback function that was given to us.