Search an Array using X varriables

Get help using Construct 2

Post » Sun May 05, 2013 4:59 am

Hello forum Buddies,

I have populated an X,Y Array with (Random X coordinate), (Random Y coordinate), and other info about a sprite that will eventually be placed on the screen. So each Y axis line is a new object with x,y coordinates.

I also created a Dropdown box that lists each object location as X,Y. This box is populated in the for next loop creating the random coordinates.

How would I do a search of the Array to find the Y line (I need CurY of Array) where X0 = tokenat(List.SelectedText,0,",") and X1 = tokenat(List.SelectedText,1,",")? It would start with-> List: on selection changed

Example: ARRAY
      X0 , X1
Y0    213 , 435
Y1    123 , 654

Example:Dropdown List
213,435
123,654
B
192
S
6
G
7
Posts: 213
Reputation: 10,178

Post » Sun May 05, 2013 8:30 am

I think I know what your asking. If I'm wrong. Sorry, but your 3rd paragraph is throwing me.

search = int(tokenat(List.SelectedText,0,",") )
xIndex = Array.indexof(search)
xpos = Array.At(xIndex, 0)
ypos = Array.At(xIndex, 1)


you will have to validate both values. but I think this is the direction your looking at.
B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834

Post » Mon May 06, 2013 5:02 am

I have decided that a Hash table might do the trick a little better... I am going to try that rout.
B
192
S
6
G
7
Posts: 213
Reputation: 10,178


Return to How do I....?

Who is online

Users browsing this forum: Callan S, getplay, Kagubro and 21 guests