troubles loading json data

0 favourites
  • 3 posts
From the Asset Store
Data+ is the best Data Management solution for Construct 3. It contains 4 Addons (Plugin & Behavior).
  • my goal is to save the positions and types (which sprite is it) of my sprites into json data, so that i can load unique levels to my game. i'm also using a dictionary to manage the data. i have a key for the xposition, yposition, and type. when the game starts up it should take the json data from the file and create the objects in their appropriate positions.

    my problem is loading the json data from the file. i imported the json file to my files folder in the project.

    dropbox.com/s/0v6fzf6co8x97b6/example.capx

    any help is appreciated <img src="smileys/smiley10.gif" border="0" align="middle" />

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hey jaketakelake. I think you're misunderstanding how the JSON object works. JSON is a format for expressing arrays in a string.

    When you tell Construct to "Load from JSON string" you are supplying the value "examplelevel.json". However, this doesn't actually have anything to do with the file in your Files folder. It's just a literal string, so Construct attempts to parse "examplelevel.json" - which isn't a valid JSON string in itself - and unsurprisingly nothing happens.

    So, what are your options? You have two as far as I can see. You can use the AJAX object to request a JSON string from a PHP page, and store your levels in a server somewhere. This is a fairly simple solution if you have access to a server.

    Alternatively, if you are developing for desktop, you should be able to use Node-Webkit's File IO functions to retrieve the contents of your level.

    To reiterate: The Load JSON action requires a JSON string, which right now you are not providing. There is no way that I am aware of to access this file when it is in the Files folder.

  • thanks. i understand. do you recommend a better way to load multiple levels?

    edit: I tried your first option. I used ajax to request the "examplelevel.json". How do i transfer the data to a dictionary?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)