How do I check an array with one instance and not all of them?

0 favourites
  • 5 posts
From the Asset Store
2D fighting template based in the game that defined the fighting games genre.
  • I am making a skins menu for my game, and I'm using an array to store if each skin is unlocked (0 for no, 1 for yes). Each button for the skins is just an instance of a base object to make it easier, and each instance has an ID variable to see which skin it is. I have an event that checks the array slot corresponding to the skin with the ID (So Check X -> if SkinButton.id = 1, do actions). If the slot is 0 (locked) I want the button to be black (I used Set Color rgbEx(0, 0, 0)) but if it's 1, reset the color.

    The issue is that it checks for all instances, meaning if just one is locked, they all set the color to 0, 0, 0. How can I check the array for each individual instance instead of all of them?

    Sorry if I worded it weird.

  • Ok so you went with the array option that's good, can you elaborate on this part : I have an event that checks the array slot corresponding to the skin with the ID (So Check X -> if SkinButton.id = 1, do actions). What does the event look like? I know how to resolve this, that's why I suggested an array I'm just wondering what you tried here and where it went wrong.

  • can you elaborate on this part

    Yeah. On the event sheet that the layout uses, I have an event that has the array check "If SkinButton.id = 1" If it is true, then reset the color, if not, make it black. The array itself is 35 x 1 x 1, meaning I just use Check X. Since each SkinButton instance has a different value for the ID variable, it checks the slot that matches with that ID. (So Skin #3 would check slot 3)

    Did this explain it well enough?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I guess I should've asked for a screenshot haha but the way I would do it is this - have a variable for the array position, I guess you have this called ID. Then another variable for whether it is locked this is set to array.at(variable1) 'for each' button. This should leave the buttons with 0 or 1 for variable2.

  • This should leave the buttons with 0 or 1 for variable2.

    It worked! Thank you.

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