How do I control spawning locations

0 favourites
  • 2 posts
From the Asset Store
Huge collection of icons like internet, setting , wi-fi, upload, download, recycle, location and much more
  • I want to spawn a sprite at a random place on my layout - however I don't want the sprite to be created within 25 pixels of any existing sprite; how would I go about this?

    Cheers guys

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Put all of the sprites into a family.

    Spawn an invisible round sprite however you would randomly.

    Give the invisible sprite fade behavior with it set destroy when fade is finished.

    Choose the fade out time in properties.

    Then create dual condition:

    Invisible sprite on created >

    Is overlapping > Family > Spawn > Whatever sprite

    Else > Spawn an invisible sprite however you would randomly again

    (x) being inverted

    If the Invisible sprite is not overlapping of the existing family sprite, then you new sprite gets spawned, if not, nothing gets spawned and it tries again. Remember to set the invisible circle sprites collision in the circle shape.

    You could create a function to create the Invisible sprite. It's the invisible sprite that's used to create the real sprite that you want to spawn and then it is destroyed, never being seen.

    Hope this helps

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