Make Sprites Spawn at Specific But Random Spots

0 favourites
  • 6 posts
From the Asset Store
Easily generate many levels from a set of pre-built scenes (Construct 3 template)
  • Hi guys,

    I'm having trouble getting enemies to spawn where I want them to.

    I do want them to spawn randomly, but I wanted it to be random on top of a certain other sprites I am using as a clear floor tile, or anywhere there isn't a solid tile like a tree or stone.

    I tried this way, logically speaking:

    On instance of SpriteFloorTile >>> pick a random number from 0, 6

    if that random number = 3 >>> Create Monster on THAT SPECIFIC INSTANCE of SpriteFloorTile

    and I've also tried spawning them randomly via the every x seconds thing, but I really want there to be a set number of enemies per level (ex: 10 for this one).

    Pic and cap below, the white boxes are my enemies for now :3

    <img src="http://dl.dropbox.com/u/93047429/test.png" border="0">

    Capx

    SEPARATE ISSUE:

    My whole layout seems to be inset by about 32 pixels. That's where the black bars are around the edges of the layout. Any ideas what this could be or how to fix it?

  • When you say "specific but random" points, do you mean...

    * having a certain number of static "spawning points" and choosing one of them, or

    * spawning objects on random points but meeting a set of conditions?

  • * spawning objects on random points but meeting a set of conditions?

    that one. basically anywhere that is NOT solid. and such that there are a maximum number of monsters on the map that decreases as the player encounters and defeats them. So for example, ten random monsters spawning on any NON SOLID point on the layout, and once a player defeats one, there are 9 monsters remaining, etc...

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Here's a possible solution:

    https://skydrive.live.com/redir?resid=EA6D2E6BFF35AC87!111&authkey=!AC-bkLJt6FM5rK4

    I think it's easier to spawn an enemy at a random point, check if it's overlapping a solid object -here you could make an "or" block or create a family from all solid objects- and if it does, discard it (that is, destroy it)

    I don't know if you can check collisions right when the object is created.

    Hope it helps!

  • Totally works. Dude you just went above and beyond! I really can't thank you enough. You are definitely going in the credits :D!

    Really, thanks so much again! <img src="smileys/smiley32.gif" border="0" align="middle" />

  • Totally works. Dude you just went above and beyond! I really can't thank you enough. You are definitely going in the credits :D!

    Really, thanks so much again! <img src="smileys/smiley32.gif" border="0" align="middle" />

    I'm glad I could help <img src="smileys/smiley2.gif" border="0" align="middle" />

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