I have some sprite sheets with the atlus saved in a JSON format. I'm structuring my atlus based upon the structure from BrowserQuest. Each of their JSON files looks like:
{ "id": "agent", "width": 24, "height": 24, "animations": { "idle_down": { "length": 2, "row": 0 } }, "offset_x": -4, "offset_y": -8 }
But I'm wondering, how do I even access the data in each JSON file, if it just a raw object literal?
Since each JSON file is an object literal, the only way I could imagine accessing it is to save the object literal to a variable, such as
var agent = {
"id": "agent",
"width": 24,
"height": 24,
"animations": {
"idle_down": {
"length": 2,
"row": 0
}
},
"offset_x": -4,
"offset_y": -8
};
I'm hoping there is an easy way to access JSON files.
And because each individual sprite sheet has its own JSON file, I have a large number of files to load.
What is the best way to load such a high number of JSON files? I'm trying to avoid using any JS libraries.
$.getJSON?JSON.parsethe response. However--quite frankly--that's rather silly when all the work for this and hundreds of other things is already done by jQuery.copycommand will work.copy file1+file2+file3 bigfile.js