Comparing Adjacent Arrays

0 favourites
  • 7 posts
  • 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

    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



  • 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?

  • 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.

  • See if this helps: ... 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.

  • 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.

    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.


  • Anyone? :/

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)