How do I spawn random sprite from spawner?

Get help using Construct 2

Post » Thu Nov 26, 2015 7:34 pm

Hello there, trying to make my first game using Construct.

So, there are 5 spawners, that should spawn any of 5 random sprites every second.

1. How to pick a random sprite spawned by single spawner?
2. How to make spawners not to spawn twice in a row? (in this case sprites overlap each other)

Any help would be much appreciated,
Thank you.
B
3
Posts: 2
Reputation: 179

Post » Thu Nov 26, 2015 7:51 pm

add your 5 sprites to a family. Instead of spawn sprite you just spawn family and this will pick one of the sprites from the family group at random

How to prevent your spawn point been picked straight away again…

give your spawn points Boolean instance variable (called for example "busy")
give your spawn points a timer behaviour
then in your code you will have an event which say something like
every X seconds
add a 2nd condition which says
pick all the spawn points that are not "busy"
add a 3rd condition which says
from all of these available spawn points pick one at random

The action to this condition is
from this spawn point spawn a member of the family
set the timer on this spawn point for a suitable delay
set the instant variable Boolean "busy" to true

add a new condition/action which says
when the spawn point timer is up reset its instance variable Boolean "busy" to false

Hope this makes sense?

edit

Image
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
33
G
47
Posts: 1,194
Reputation: 30,782

Post » Fri Nov 27, 2015 1:30 pm

Wow, Thank you so much. Everything works as it should now!
B
3
Posts: 2
Reputation: 179

Post » Tue Feb 14, 2017 5:05 am

is there any possibles way to make this ? without families ?
B
6
Posts: 1
Reputation: 263

Post » Tue Feb 14, 2017 6:29 am

Just do it manually. Generate a random int, and use If Else to decode the value and create each type based on the value.
ImageImageImage
B
71
S
20
G
192
Posts: 3,535
Reputation: 109,344


Return to How do I....?

Who is online

Users browsing this forum: ilyaTyl, SoldjahBoy and 10 guests