Hello.
I can obtain a new shuffled array from another one ('temp') when a botton is pressed. I use a function but it doesn't work when I call it again ('temp' array is empty). What am I doing wrong?
And this is the result in a browser (it works the first time).
Thanks in advance.
Develop games in your browser. Powerful, performant & highly capable.
As you said, your temp array is empty the second time you call shuffle... So before you shuffle, you need to rebuild your temp array. Either copy your current array to the temp array to shuffle the remaining cards, or populate it from scratch.
Thanks for your reply. I call init function and then shuffle function but it doesn't work.
Try setting the size of the temp array upon calling the function, rather than in the loop?
That works! I set the size of the temp array at start of init function, out the loop.
Thanks very much.
One more question about this code:
How can I asign the elements of 'new' array to the five objects in a loop? I can only add action to each object, one by one.
Thanks again.