Comparing Adjacent Arrays

Get help using Construct 2

Post » Thu Feb 20, 2014 2:29 pm

Hello,
I have a grid of randomized objects I want to compare the adjacent arrays (North, south, west, east) to the selected tile so that I have an area of those objects
Image
If you highlight that one tile (variable = highlight) it should compare CurValue (0,1,2,3 etc) and highlight it too
Why doesnt this work :S

Yours,
Black2key
B
19
S
5
G
5
Posts: 27
Reputation: 4,257

Post » Thu Feb 20, 2014 3:05 pm

First, you aren't checking your indicies for valid values (if curX = 0, then curX-1 is -1, not a valid index).
Second, you aren't picking the appropriate tile, you keep setting the value for the currently picked tile. You should set the selected tile's highlight outside of the For-loop and then pick-all to reset, then run the loop, picking the appropriate tile.
How are you referencing the tile to the array indicies?
B
71
S
22
G
241
Posts: 3,734
Reputation: 134,494

Post » Thu Feb 20, 2014 4:45 pm

I am not sure I get what you are trying to tell me, quite new @ arrays, but lets go.
1. So, I should stop the loop when it goes into negative values? I mean, if there is no Array there, it will just stop automatically or should I manually tell the loop to stop IF 0?
2. I almost figured that this kept happening and even if it checked the neighbouring tiles it would only change the value of the currently picked tile. How do I change the value of objects in an indice that is not even active? (still have to get my head arround these expressions). So I should highlight it -> pick all -> loop?
3.The Array has a randomized Instance Variable that selects the frame of the tile.
B
19
S
5
G
5
Posts: 27
Reputation: 4,257

Post » Thu Feb 20, 2014 6:33 pm

See if this helps: http://blackhornettechnologies.com/Cons ... light.capx

The key is the array has a UID to the Sprite, and the Sprite has the indices into the array, so that either can get to the other, depending on who needs to do what.
B
71
S
22
G
241
Posts: 3,734
Reputation: 134,494

Post » Fri Feb 21, 2014 1:36 am

Thanks for the help, I am really greatful! but another problem arises, I have a completely random map with x colours.
And, if I select a tile, it should highlight all the tiles with the same frame/colour.
Image
So if you hover over one of the five red it should highlight all of them, so comparing uid's doesnt do the trick here!
I uploaded a capx with just the problem to illustrate that.
ho.capx
B
19
S
5
G
5
Posts: 27
Reputation: 4,257

Post » Fri Feb 21, 2014 12:26 pm

Anyone? :/
B
19
S
5
G
5
Posts: 27
Reputation: 4,257

Post » Fri Feb 21, 2014 3:17 pm

B
71
S
22
G
241
Posts: 3,734
Reputation: 134,494


Return to How do I....?

Who is online

Users browsing this forum: TRMG and 39 guests