Return to Video

Batches - HTML5 Game Development

  • 0:00 - 0:03
    Hi, welcome back to the show. Let's walk through the solution for this one
  • 0:03 - 0:06
    because it's just a little bit tricky. First, we need to keep some sort of
  • 0:06 - 0:10
    count on how many of the assets have been loaded and how many we're waiting to
  • 0:10 - 0:14
    load. To do this, we create a nifty little object here, that has a count that
  • 0:14 - 0:17
    represents how many objects have been loaded, a total which is how many objects
  • 0:17 - 0:22
    we're waiting to load, and then the given call back function. Now we want to
  • 0:22 - 0:24
    take our code, which previously only loaded one asset and issued a call back,
  • 0:24 - 0:29
    and add loop around it so that we can do this for the entire asset list. Now,
  • 0:29 - 0:32
    there's one tricky thing here, is that once we actually load an object and get
  • 0:32 - 0:35
    a call back function for it, we want to do some logic before we issue the call
  • 0:35 - 0:39
    back. So for instance once the first image is loaded, we don't want to issue
  • 0:39 - 0:43
    the call back then, we want to wait until the entire set has been loaded. For
  • 0:43 - 0:47
    this, we added the new function called onLoadedCallback. This function, given
  • 0:47 - 0:50
    an asset that's been loaded, will actually go through and increase the count on
  • 0:50 - 0:53
    the batch. Once our count equals that total number of assets we're waiting for,
  • 0:53 - 0:57
    we actually issue the callback at that time. With this setup, you have the
  • 0:57 - 1:00
    ability to issue a batch of assets, load them, and when they've all been
  • 1:00 - 1:03
    loaded, you finally get your callback.
Tytuł:
Batches - HTML5 Game Development
Opis:

more » « less
Video Language:
English
Team:
Udacity
Projekt:
CS255 - HTML5 Game Development
Duration:
01:04

English subtitles

Revisions Compare revisions