How do I check multiple array entries?

0 favourites
  • 6 posts
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • I'm trying to compare multiple entries in 2 different arrays.

    I'm able to do it but only if I compare each entry individually, this isn't a problem when I'm just comparing a few entries. However, this is going to be for a larger project so I need a better way of doing it.

    My current way is like this:

    Each element of the user array is compared against the answer array, but only one by one. I've tried doing it in a for loop, but this then doesn't to work it only looks at the last element.

    a sample of the project is here:

    surely there must be a more elegant way of doing this... been trying all day and it's driving me mad!!

    thanks for any help


  • Instead of the changing Y co-ords use 'loopindex' and put it inside a for loop from 0 to array.length

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I had already tried that it is doesn't work.

    The issue with it is that it doesn't compare all the elements.

    As long as one element matches, it thinks they all do.

  • Well the compare will work, but in terms of saying something matches, you are changing the animation frame of a tick to determine this yeah but the tick doesn't relate to anything. So the output will be like TrueFalseTrueFalse within the loop but then you change the animation frame of a tick which needs to correspond to the co-ords you're currently checking. Sorry I've not downloaded the file I'm out right now just lookin at this.

  • ah yes of course.

    a quick and simple fix will be to add a counter

    for each correctly matched add +1 to the counter, when that's equal to the array.length the tick can move to the correct animation frame

    there's probably a better way of doing it but I'll give this a try

  • Just looked at the file. Yeah a local variable counter is a nice idea and compare with number of expected correct answers.

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