How do I get array line that matches to conditions ?

0 favourites
  • 3 posts
From the Asset Store
solution for games like "fruit ninja" and drawing applications
  • Information for the sprites are stored in sprite variables.

    Two variables are manually assigned to the sprites :

    - Episode

    - Sequence

    Name variable has to be assigned runtime from the following array

    I made a "for each sprite loop" to look into the array and pick the sprite that matches two conditions :

    - Array.At(Array.IndexOf("Episode"),Array.IndexOf(Sprite.Episode)) = Sprite.Episode

    - Array.At(Array.IndexOf("Sequance"),Array.IndexOf(Sprite.Sequence)) = Sprite.Sequence

    How do I get the line index of the line that matches the two conditions ?

    Tagged:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Is that screenshot from the array editor in Construct?

    Column names in the array editor are just for convenience, you can't use them in expressions.

    You need to loop through the array on its Y axis, comparing elements at X=0 and X=1 with the instance variables on the sprite:

    For each Sprite
     Repeat Array.height times
     Array.At(0,loopindex) = Sprite.Episode
     Array.At(1,loopindex) = Sprite.Sequence 
     --> Sprite Set animation to Array.At(2,loopindex)
    
  • Thank you very much ! It works very well.

    Actually, I'm keeping column names and use them to find out the column number because I may have later to reorganise the array and thus won't have to change the numbers.

    Here's the code I'm using :

    array.At(Array.At(Array.IndexOf("Episode"),loopindex), loopindex)

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