How do I create and position object with xml file

0 favourites
  • 4 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • Hey guys Id like to know how do I create objects with xml files.

    XML Code

    "<?xml version=""1.0""?>
    <build>
    <xpos>500</xpos>
    <ypos>500</ypos>
    </build>
    
    <build>
    <xpos>100</xpos>
    <ypos>200</ypos>
    </build>
    "
    [/code:187dx0xk]
    
    [b]The event[/b]
    [img="http://4.ii.gl/KcSqaN_vP.png"]
    
    [b]This are the result of this code & event.[/b]
    [img="http://1.ii.gl/-UWmBSaPJ.jpg"]
    
    [b]I was expecting to get this result but it fail.[/b]
    [img="http://3.ii.gl/ELKktlbf.jpg"]
    
    Please guide me to set things right.
  • You need a root element. You can only have one root element in an XML file.

    "<?xml version=""1.0""?>
    <builds>
      <build>
        <xpos>500</xpos>
        <ypos>500</ypos>
      </build>
    
      <build>
        <xpos>100</xpos>
        <ypos>200</ypos>
      </build>
    </builds>
    "
    [/code:a3ah0qg7]
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • ramones Thank you for that. I fixed it with this code

    "<?xml version=""1.0""?>
    <object>
    
    <build id=""0"">
    <xpos>250</xpos>
    <ypos>250</ypos>
    </build>
    
    <build id=""1"">
    <xpos>350</xpos>
    <ypos>250</ypos>
    </build>
    
    </object>"
    [/code:16q6eh65]
    
    Now I'm trying to assign the [b]object instant variable[/b] with the build id in the code above and the event below. Its not working.
    [img="http://4.ii.gl/T1nAIsK-.jpg"]
  • Set oid to XML.NumberValue("@id") and put that just below the "create object Sprite" action.

    Also for it to work in IE you'd need to use "xpos/text()" and "ypos/text()".

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