How to create different objects based on the UIDS stored in my array?

0 favourites
  • 5 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hello!

    At the beginning of the turn of my card game I create an object from the cards family in an empty slot in the player's hand and store the UID of this object in my array. Before creating the next card, I would like to compare its UID with what exists in the array, and not creating it if the uid of the letter already exists, would be a way to avoid creating repeated letters, could you help me?

  • I would have two arrays, one permanent with a list of cards with their unique number and properties.

    The other with the cards in the player's hand.

    And when generating a new card, I can select a random card from the first array and check if the player has such a card in the array. If there is, I select another random card again, if not, I show it to the player and stop the selection automaton.

    I don't know if I've made myself clear.

    I do not have a ready example, but recently I did an example with the selection of skils and there too skils that have reached the maximum level were not offered to the player. Take a look.

    c3p

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you very much.

    I'll take a look at your material and get back to you with more questions if there are still any.

  • c3p

    I created a simple example.

    There is a pool of cards from which we give cards to a player without repeating.

  • With text box I managed as follows:shuffled the array,generated the value of X,0 and then deleted the element x,0, after that the array was automatically reorganized and the positionx,0 gained a new value, so when I repeated the action, I just shuffled the array elements again and repeated the process, since the previous result would not be repeated due to having been deleted

    My problem is generating the sprites without repetition from what I have in the array. The idea was to go through the array and only generate the sprite if its UID was not in it, but I can only generate the card and write the UID to the array, when I need to generate a second card, I cannot consult the array and only generate the card if his UID is not there. I think this happens because I can't consult a UID of a sprite that hasn't been created yet, maybe I need to create and destroy it if the UID is in the array

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