How do I create and position object with xml file

Get help using Construct 2

Post » Sun Apr 26, 2015 10:14 am

Hey guys Id like to know how do I create objects with xml files.

XML Code
Code: Select all
"<?xml version=""1.0""?>
<build>
<xpos>500</xpos>
<ypos>500</ypos>
</build>

<build>
<xpos>100</xpos>
<ypos>200</ypos>
</build>
"


The event
Image

This are the result of this code & event.
Image

I was expecting to get this result but it fail.
Image

Please guide me to set things right.
B
15
S
3
Posts: 57
Reputation: 909

Post » Sun Apr 26, 2015 10:45 am

You need a root element. You can only have one root element in an XML file.

Code: Select all
"<?xml version=""1.0""?>
<builds>
  <build>
    <xpos>500</xpos>
    <ypos>500</ypos>
  </build>

  <build>
    <xpos>100</xpos>
    <ypos>200</ypos>
  </build>
</builds>
"
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,670

Post » Sun Apr 26, 2015 11:22 am

@Ramones Thank you for that. I fixed it with this code
Code: Select all
"<?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>"


Now I'm trying to assign the object instant variable with the build id in the code above and the event below. Its not working.
Image
B
15
S
3
Posts: 57
Reputation: 909

Post » Sun Apr 26, 2015 1:19 pm

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()".
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,670


Return to How do I....?

Who is online

Users browsing this forum: raptor0555, Syazanie Amirin and 48 guests