Creating Custom Path in a Grid Using an Array

0 favourites
  • 4 posts
From the Asset Store
Snap to visible grid - perfect solution for any game genre
  • Helloooo.

    I'm working on an interface where the player clicks/taps on a cell in a grid and that cell is labeled with a value of 1 through 5. First click/tap, 1; second click/tap, 2; etc. At any time, the player can deselect any of the highlighted cells. Thus, if 1 through 3 is selected and the player deselects the 2 cell, the 3 cell becomes the new 2.

    The purpose of this is because my character will follow the customized path devised by the player - the order of the selected cells will determine that path.

    I initially figured using an array and pushing the UID of that selected cell node onto the back of the array. No problem there. Adding the UID values into the array is good.

    The problem is IDENTIFYING the correct index in the array that has the UID value of the cell node when DESELECTING it (and thus deleting that array element).

    So far, I can't QUITE think of a succinct method to DESELECT cells and thereby update that order of selected cells.

    Any suggestions? THANKS!

  • Hey Rhindon!

    When a player deselects a cell, run a Repeat x times loop, in which x is the array.Width. Inside the loop, check the value stored in the array and compare it to the uid of the deselected cell, if it matches, delete the index. The array will fix indexes by itself.

    Hope this helps. Cheers!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • DUUUUUUUUDE!!!! So obvious, ! But leave it to me to miss it. LOL I will get to work on that and see if it meets my needs...but I'm pretty sure it will. Thank you so much!

  • [Please pardon my exuberant emotional outburst of joy. ... Given my struggles at game design and learning C2, I feel I've earned it. LOL] IT WOOOOORKED!!!!! Absolutely PERFECTLY!!! Exactly as I planning. Thank you again!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)