I want to spawn sprites in a square on function.
This means that if I spawn 4 sprites, they'll be in a 2x2, or if I decide to spawn 100 sprites, they will be 10x10.
How do I do this with the least amount of events?
If you are always going to spawn a perfect square just pass the function the square side (like 3 for 9 sprite spawn then walk the location around in a double for loop from 1 to 3 in both x and y spawning once for each x,y location pair.
you may also want to pass the lower_x and lower_y as the cornter of the spawn area and then add that to each x,y pair as the offset_
Literally it's all about mathematical function that called square root. For example given number is 625 so both axis will have 25 each. My approach would be just utilizing "for" loops to create the grid of object.
Here you may have it: dropbox.com/s/l7gfwtbo6y2h6zi/squared_generator.capx
Develop games in your browser. Powerful, performant & highly capable.
Thank you alextro! I've never used the "For" Loop before, but that's a perfect example. *Bowing in graditute*