cincipon's Forum Posts

  • Ellipsis

    And try the search function on the forums (should be a badge for that!)

  • Figuring out who what a JSON is

    We are talking in this thread about how to figure out what a JSON should look like.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • From your example it seems like it'll be fine, unless you have some more complicated relationships you haven't mentioned. You can use each level's dictionary object as a row in your 'table', and the key/value pairs in each dictionary will be the columns.

    QUOTE --> (i.e. each level will have associated with it a name, sequence number, etc.) <---QUOTE

    If this is as complicated as it gets, then each level could be loaded into a dictionary, either one dictionary that you clear and reload on each level change, or a dictionary for each level if that works better (no clue here).

    If your data is more complicated than that, then perhaps if you post a tiny example we can come up with something that'll handle it.

    It's a shame you can't just make a dictionary of dictionaries! (Unless you can?)

  • As for AJAX, it is a method for getting information to and from a web page asynchronously. In other words background transfer of information.

    If you find your program takes forever to load, perhaps then AJAX will be a useful addition, but for the moment, getting your levels to load at all might take precedence. Function, then Faster!

    (@Squiddster Love your art btw!)

  • JSON is another set of letters, like XML. It doesn't really matter what it is =P But for your sake, make a new construct program, and add a dictionary. Then make some events to add your key values to the dictionary (just a few). Then do something like: On condition (finished filling dictionary (or whatever)) -> Dictionary.DownloadJSON.

    That will download a JSON file to your computer. Use a text editor and open it up and see how it is structured. It is structured simply, but I'm not precisely sure how in this case. Once you see it, you can replace the key/values you used for this demo with your REAL key value pairs, and load it into your game via the dictionary object's LoadJSON function.

    JSON:

    {"menu": {

    "id": "file",

    "value": "File",

    "popup": {

        "menuitem": [       {"value": "New", "onclick": "CreateNewDoc()"},       {"value": "Open", "onclick": "OpenDoc()"},       {"value": "Close", "onclick": "CloseDoc()"}     ]

    }

    }}

    The same text expressed as XML:

    <menu id="file" value="File">

    <popup>

        <menuitem value="New" onclick="CreateNewDoc()" />

        <menuitem value="Open" onclick="OpenDoc()" />

        <menuitem value="Close" onclick="CloseDoc()" />

    </popup>

    </menu>

  • I'm pretty sure that for loading your levels into dictionary, you could convert your xml into json, and then use the dictionary classes method to load the json info into the dictionary.

    The conversion from xml to json is trivial if you google it.

    As for the other part, The Dictionary Manual Pageshows an action to read from JSON, so I would try that.

    To see the format to use, make a tiny dictionary, and save it to json, then convert that to xml and see how it looks, then build backwards from there.

  • The formula is animation speed = frames per second.

    This explains the art side a little bit.

  • I believe the numbers you set in the animation properties panel is fps for the particular animation. So if you set 10 for your walk and sword for 15, the walk animation is going through its frames more slowly than the sword animation is.

    You have two options, really. You can either insert extra frames into certain animations, and standardize your animation fps, or, once you've animated an object, decide how long the action should take and divide the length it should take by the number of frames. (e.g. if you want your walk cycle to take 1 second, and you have 8 frames, set it to 8, and voila!)

    I am unsure how the interface handles non-integer values well, or at all, so you might not be able to get it perfectly synched if you follow the second method.

  • Could you store the A, B, C part in an instance variable? So that when the player collides with an exit that leads to entrance A, you set a global variable to A, and when you load the new layout you set the player's location to Entrance who's instance variable is == (the global you set)?

    You'd want to set up an instance variable for each direction on each entrance/exit, unless they are one-directional.

  • This javascript example will get you on your way if you want to make a plugin to do it.

  • Hmm. I see that your problem is more complicated than I thought from your description.

    If you want the magnet to repulse, perhaps it would be best tomake an invisible sprite around it, and when the player collides with the trigger sprite you could send it a physics impulse based on the angle between the player and the magnet?

    As it stands now, your code has too much going on aside from the problem at hand for me to jump into.

    Good luck!

  • The reason is that .3333333333333333333 is not 1/3. It is an approximation of 1/3, and to go between the two needs some human judgement, e.g. IF statements.

  • I am almost certain that there is no simple function. The simple method is as I described. Decide upon a precision threshold, and check the digits to the right of the decimal place. There is a method to truncate into an integer, so you can make two strings and concatenate them. so your 8/3 as 2.333333 becomes 2 and 1/3.