How do I random array entry

Get help using Construct 2

Post » Fri Jan 23, 2015 3:28 pm

Attempting to create a background selector for users to choose different BK's while playing the game - I have possible 6 options they can choose 1, 2 ,3 , 4, 5 ,6 or all 6

so I was using every 5.0secs SET BK to array(choose(0,1,2,3,4,5)) problem is some them keys are empty if they didn't select all 6 if they just choose 1 or 2

BK is a global and it's then setting a sprite from URL using that BK name

how can I before doing that step check what keys are filled and only use them keys in the choose statement?
You do not have the required permissions to view the files attached to this post.
Need Sprites For Your Next Project?
100% Vector Animated Sprites
Posts: 170
Reputation: 1,086

Post » Fri Jan 23, 2015 9:30 pm

Instead of having an array with empty values, start with an array of width 0 and only add the selected backgrounds to it. So if you select 3 backgrounds then the array width will be 3. Then you can select a random one with Array.At(floor(random(Array.Width))).
Posts: 1,520
Reputation: 25,860

Return to How do I....?

Who is online

Users browsing this forum: atmas and 11 guests