UIDs into Arrays

Get help using Construct 2

Post » Thu Jun 28, 2012 5:23 am

Arrays are killing me. How do I get the UIDs of 4 instances of one object into 4 slots in an array?

I created an object, dragged 4 instances of it to the Layout. Then I created an array on the layout and get it dimensions of 4,1,1.

On the event sheet I tried:
Array>For Each element on the event
Array>Set Value at Arrayname.At(loopindex) to objectname.UID on the action

It doesn't seem to work and I can't figure out where it's messed up. Can anyone help explain this concept? Once the UIDs are in the array, I think I know how to use the array with For Each statemes.

Thank you in advance for any help
B
15
S
6
Posts: 17
Reputation: 1,927

Post » Thu Jun 28, 2012 5:32 am

put the capx it will help us to know the problem , about arrays they sets variable as x,y and they can store many value

put a variable in the object
B
45
S
15
G
6
Posts: 795
Reputation: 11,935

Post » Thu Jun 28, 2012 5:46 pm

your goin about it backwards. You dont loop thru the array to assign the UIDs you loop thru the objects to assign the UIDs

theres no loopindex for "for each" so make a local var and in the for each add 1 to it AFTER you assign the UID to the array.

for each "object" -> Set Value At "count var" to object.UID
Add 1 to "count var".

Now your array will contain the UIDs. You can also dynamically size the array to the number of objects but it has to be done before you start assigning values to the array
B
13
S
5
G
2
Posts: 306
Reputation: 3,262


Return to How do I....?

Who is online

Users browsing this forum: dewetberg, RickUSBstick, Yura G and 24 guests