How do I filter my array by Y index?

  • EDIT: All images seem to be way too big for the forum, I resized them on imgur (they are 150 pixels wide) but it somehow still doesn't work properly. Here are the full images until I figure this out, sorry! https://imgur.com/a/ERua5

    Hello, Construct community! <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    I'm doing a menu where I have different food categories, in each category, different food items are available.

    The idea is to destroy the list and instantiates the proper food list sprites depending on which category is active. Here it would be to have only green items in one category, and only blue ones in the other.

    My array is working, my categories are too, and my generated food list kinda does too. Now let me show you the array:

    And here is what I currently do, which properly generates content and don't generate sprites for the empty array cells:

    What I want to do is to filter each category and only get cells on a specific y index; like in one case get all values in y=1 and in the other all values at y=1. I didn't find any good solution to do it, and it kinda drives me crazy because that's pretty basic <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy">.

    Have you an idea on how to do it? Thanks for your help!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I do this with a for loop.

    For "0 to array.width"

    Array value at loopindex,1

    That'll print 0,1 1,1 2,1 3,1 etc, everything at y=1.

  • Simple and smart solution, thanks! It works well

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