search in array for value

0 favourites
  • 4 posts
From the Asset Store
Searching
$16 USD
Searching is a game where you are challenged to find all the images with the requested letter in 30 seconds.
  • hey guys i am looking for a way to search through a row of a 2D Array, let's say i want to check for every X in Y=4, if the value is "1". and then do an action for every 1 found. i also need to use the x value for the found 1 as an expression.

    i have searched through the forum and didnt find something. i haven't got much experience with for-loops, but with arrays.

    so i guess the best solution is to do it with a for loop. i tried some stuff but didnt get it to work.

    somebody can help?

    thanks in advance

    phil

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'd do something like this, but there might be better ways:

    for each xy element

    system compare two values : Array.CurY = 4

    Array compare value = 1

    oh in the action following you can use Array.CurX in the expression

  • LittleStain

    thank you once more for your quick answer!

    i actually got mine to work right now, seems like i just misschanged something. it looks like this:

    system for "check" from 1 to 4

    -> [array], Value at (loopindex, 2) = 0

    -c> object instance variable = loopindex -> destroy

    -c> this is an additional condition and the -> a sub-event. then i threw in some more conditions for everything i want to destroy with the instance variable, which has a 0 in the array at It's X.

  • An alternative:

    searcharray.capx

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