YouTube

Got a YouTube account?

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

English subtitles

← Parsing Tiled Output - HTML5 Game Development

Get Embed Code
5 Languages

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

  1. Loading these TILEDmaps is actually a pretty complex process, so we're going to
  2. walk through it piece by piece. First, to parse the JSON, you'll notice that
  3. we've actually modified our load function call to call parseMapJSON with the
  4. data we get from our xhr request. Now the data we've received from the internet
  5. is actually a JSON blob. The first thing we need to do is actually call
  6. JSON.parse, passing the JSON blob, to actually give us an object in Javascript.
  7. Next, what we'd like to do is to actually cache some of the values of this new
  8. JSON object inside of the map class itself, so, we don't have to keep walking
  9. through and querying that data object later on. The parameters we care about
  10. keeping track of right now are the total number of tiles crossing down in the
  11. atlas. The size of each of those tiles in pixels, and then the size of the
  12. entire map in pixels. Now, once you've retrieved that data from our JSON object,
  13. go ahead and set the fullyLoaded attribute to true.