Load data from simple external Json file

Get help using Construct 2

Post » Wed May 29, 2013 2:31 pm

Hi guys,
Im just after 4 hours searching marathon. I found two plugins and many hints, but I just started with Construct and Im totaly confused. Please help with this simple task - Im lost.

I have a json file on my server. In this file there are stored several information.

It looks standard like this:

{"game":"10"},{"user":"1"},{"score":"1000"}

I need to read this file in Construct and show these data on screen to the player. Best will be to save each into separate variable.

Sorry for basic question, but I didnt found easy answer.
Check out my Android games (via Constrcut 2 / Intel XDK Crosswalk):

Mushroom Run

Free snake

Wanna bring your HighScore game to nice Freegame.cz community? PM me.
B
11
S
2
G
2
Posts: 5
Reputation: 1,362

Post » Wed May 29, 2013 4:07 pm

You can load Json strings into a dictionnary object, which can be displayed later, I think the Json string must be written in a certain way (for C2 to understand it is a dictionnary), I can try to found it if you want.

1/EDIT, the Json File you have should contain:

{"c2dictionary":true,"data":{"game":"10"},{"user":"1"},{"score":"1000"}}

or simply, you get your actual file, and add the {"c2dictionary":true,"data": and teh last } later

2/To load the Json, is it a file in C2, or hosted on a server(the AJAX object can use a GET request to get a Json file from a server If I remember)?Aphrodite2013-05-29 16:14:38
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
43
S
18
G
18
Posts: 2,106
Reputation: 16,436


Return to How do I....?

Who is online

Users browsing this forum: clarkkentnicdao and 2 guests