How do I populate a layer with sprites that don't repeat?

0 favourites
  • 4 posts
From the Asset Store
Tap the ball, control it, avoid touching spikes and score higher!
  • Hi, I am struggling to work out how to do this in the most efficient (or simplest) was possible.

    I have 10 short sprite animations which I want to appear all over a layer, not overlapping.

    I feel like I have two options(?)

    1. Make 10 sprites, put them all in a family, make it so they are created all over the layer at random.

    or 2. (which is what I thought would be best) Make 1 sprite with 10 different animations that get randomly placed and picked in the same way.

    What I can't work out with option 2 is how the event sheet should be for randomly picking an animation, placing the sprite and then repeating without choosing what was already there?

    Does anyone have any thoughts or perspectives that could help me figure out which direction to go in?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Each of 10 sprites should have different animation, no repeats? You can name animations A1, A2, A3 etc. and do this:

    Repeat 10 times
    	Create sprite at random(layoutWidth), random(layoutHeight)
    	Sprite set animation to "A" & (loopindex+1)
    

    Spawning them without overlapping is a different problem, you can check a couple of examples here:

    howtoconstructdemos.com/spawn-objects-randomly-without-overlapping-2-capx

  • This was perfect, thank you so much.

    Finding it hard to learn these extra bits like "loopindex"

  • This was perfect, thank you so much.

    Finding it hard to learn these extra bits like "loopindex"

    Loopindex is simply the number of times the loop has repeated. It's very useful.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)