How do I load data to an array to spawn an object

Get help using Construct 2

Post » Mon Feb 27, 2017 2:49 am

so I have text that is like this

1 250 8
2 240 6
3 230 5
4 220 9
5 224 4

the first number means its order, the second is the x value, and the third is the y value.
how do I load this data to an array so I can spawn #1 at x 250 y 8 or #2 at x 240 y 6

should i make it into xml?
Code: Select all
<object>
  <num>1</num>
  <x>220</x>
  <y>4</y>
</object>
<object>
  <num>2</num>
  <x>240</x>
  <y>7</y>
</object>


but how do i load it into an array, to spawn the objects, or is that even necessary?
B
3
S
1
Posts: 1
Reputation: 277

Post » Mon Feb 27, 2017 10:58 am

At this moment, both are fine to use.
XML has that one benefit, it is easy to edit outside C2.

At a point in the nearly future (c3), Arrays will have their own 'value editor'. That will make things a LOT nicer. And bring the preference to using an array, i think.

If you choose for XML, there are a lot of tuts to help you.
https://www.scirra.com/tutorials/810/xml-example-20
https://www.scirra.com/tutorials/354/xml-parsing
There is also a template (when you make a new project, type XML in the search line)

If you choose for an array. Then specific for your question ....
You dont need the 'order', because the 'order' is already the same as the index on the X axis.
Far more easy is to start with an empty array, as in this example.

https://www.dropbox.com/s/lgad47eunduh6 ... .capx?dl=0

As you see, at this point is constructing the array tedious. If you have a lot to create, you are better of using XML.
But, that will change in the near future. And i am (personalty) very happy the new array editor.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950


Return to How do I....?

Who is online

Users browsing this forum: Artcadev, brunopalermo and 19 guests