Load values from a document

0 favourites
  • 4 posts
From the Asset Store
Progress\Loading Bar. Now Load you game like a Professional.
  • I am making a game which (in short) is an array of quests, in random order.

    When the quest_button is clicked on, I want to load a random quest. Now, the randomization is not the issue here.

    I thought about using XML:

    <?xml version="1.0" encoding="utf-8"?>
    <Title>Some Quest</Title>
    <Morale>1</Morale>
    <Strength>2</Strength>
    <Agility>3</Agility>
    <Speed>4</Speed>
    

    I can load the file using XML's load function, but how do I access the values? EG: How do I set a global variable named current_speed to the speed defined in the XML file, in this case 4.

    Of course, I do not have to stick to XML so if any of you know how to do this either with or without XML, please do help me out on this one.

  • scirra.com/tutorials/354/xml-parsing

    JSON works too if you are more into that kind of thing.

  • Usage:

    <img src="http://puu.sh/32dmD.png" border="0" />

    XML content:

    <?xml version="1.0" encoding="utf-8"?>
    <Voyage>
         <Specification title="Save The Princess" morale="1" strength="2" agility="3" speed="4"></Specification>
    </Voyage>

    voyage_widget is a sprite I use as button; when it is clicked I want it to load the XML file.

    Now, if I just pass on the actual content of the XML file in the XML.load function, Text.setText is correctly setting the title of the textfield to "Save The Princess".

    However, trying to load from file simply fails on me.

    Thanks for that link by the way, I have figured out the parsing... now it's just the loading :(

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • From: scirra.com/manual/107/ajax

    "Also, when previewing in Construct 2 the game runs on localhost. This counts as a different domain to the rest of the internet, so typically AJAX requests to any web page will fail during preview, unless the server explicitly allows cross-domain requests."

    I'll upload the exported file and see if it works, then.

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