Is it possible to read in *standard* .json files?

Get help using Construct 2

Post » Wed Mar 15, 2017 10:42 pm

I have a bunch of standard .json files that define components. I was hoping I could use C2 to parse the .json files and create a .png image; but it seems that Scirra uses a special .json format.

I've got the File Chooser working, and I can grab the text of the file using AJAX. But there doesn't seem to be a good way for me to parse the data. Is it possible?

Here's what my .json data looks like:

"name": "basic_gun",
"columns": 4,
"rows": 6,
"tileWidth": 32,
"tileHeight": 32,
"tiles": [0, 1, 2, 0, 0, 3, 7, 0, 0, 1, 1, 0, 0, 1, 1, 0, 10, 1, 1, 14, 1, 1, 1, 1],

There are only 15 values that can go in my grid (which can be variable in size). My plan is to have a 32x32 sprite for each value and lay them out appropriately by columns and rows. Then I'm hoping to be able to take a snapshot of the canvas and invoke a browser save. I'll have to change the canvas size dynamically after reading in the .json file... Is that possible?
Posts: 119
Reputation: 1,417

Post » Sun Mar 19, 2017 3:36 pm

Of course it is.

Use @Yann 's JSON plugin or @rexrainbow 's Hash plugin.
I don't check the forums much anymore, but I will receive an email for PMs.

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
Posts: 1,419
Reputation: 4,867

Return to How do I....?

Who is online

Users browsing this forum: oosyrag and 10 guests