Hundreds of features to explore
Games made in Construct
Your questions answered
Popular & trusted by schools and Universities world-wide
Construct 3 runs in the browser & works offline
Students do not need accounts with us
Our educational partners
Free education resources to use in the classroom
World class complete documentation
Official and community submitted guides
Learn and share with other game developers
Upload and play games from the Construct community
Game development stories & opinions
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.
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.
Develop games in your browser. Powerful, performant & highly capable.
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.