Make Sprites Spawn at Specific But Random Spots

Get help using Construct 2

Post » Fri Sep 14, 2012 3:28 am

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



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?
B
16
S
3
G
3
Posts: 66
Reputation: 3,629

Post » Fri Sep 14, 2012 7:03 pm

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?
B
19
S
8
G
4
Posts: 11
Reputation: 4,509

Post » Fri Sep 14, 2012 11:13 pm

[QUOTE=oravalag]
* spawning objects on random points but meeting a set of conditions?[/QUOTE]

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...
B
16
S
3
G
3
Posts: 66
Reputation: 3,629

Post » Fri Sep 21, 2012 8:12 pm

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!
B
19
S
8
G
4
Posts: 11
Reputation: 4,509

Post » Mon Sep 24, 2012 5:53 am

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! Yswellin2012-09-24 05:55:02
B
16
S
3
G
3
Posts: 66
Reputation: 3,629

Post » Sun Sep 30, 2012 10:14 am

[QUOTE=Yswellin] 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! [/QUOTE]

I'm glad I could help
B
19
S
8
G
4
Posts: 11
Reputation: 4,509


Return to How do I....?

Who is online

Users browsing this forum: Khamsou and 19 guests