Proper Way to Spawn a Random Number of Sprites?

I am a user of Construct 2 - and its methods for generating “random” things is fairly straightforward - with a lot of help in completing such a command from the event interface.

Just as an example, how would a designer generate a random number of sprites from a random x (horizontal) position with a fixed Y (vertical) position in GDevelop?

Thank you,

Greg Smith

Use Random(200) to get a number between 0 and 200.

It depends if the generated objects have to be aligned, and/or equally spaced too :confused:

I would go with something like this:

At the beginning of the scene I’m generating a random number between 0-10 and store that number in a variable.
Then I check if the number of sprites in the scene are less than the value is stored inside the variable, if yes, then create a sprite in a random X and fixed Y position after (every) 1 second. The action will run until the number of sprites in the scene is equal to the number stored in the variable. The problem with this is that, if you have some sprites already in the scene, you just want to create some more of the same sprite in random positions, you need to calculate with that. First you need to check how many sprites are present in the scene already, store that value in a variable and add the value to the random number generated at the beginning then start creating the new sprites and make sure they are aligned and spaced as you want them…

Hope it helps.