Hello!

Sorry if it is a very stupid question. Im trying to adapt a memory game learned in YT channel of BornCG.
My idea is to teach an asotiation of cards but for now I want to take a full deck of cards, shuffle it, divide in half and fill the grid with two groups of the same 26 cards. No matter what I do I get a grid of twenty six.
Here is the code I use:

In the fill deck I create the deck. Im create new deck I shuffle it, divide the array and create a new deck with two copies of the divided array. If I print the new deck size it seems ok.
That make me think that the problem is filling the array in the dealDeck function.
Hope to solve it because afterwards I will have to work to have each card with two different images 🙂.
In case it is interesting to you, I´m making it to help card magicians to rehearse on card memory work.

Thanks

  • xyz replied to this.

    RicSanchez Duplicating an array only does a shallow copy. So doing deck+deck won't duplicate the referenced nodes. You'll still have only 26 nodes although each will be referred to twice from the array. So your code in dealDeck() will call add_child() twice for each of 26 Card nodes.