creating an instance of a random object

Get help using Construct 2

Post » Wed Jul 31, 2013 8:03 pm

Hi guys,

I have 6 different sprites set up in my layout and I'm trying create an instance from one of those (randomly selected) at a fixed timing rate. I have combined all of them in a family, but I only have the option to spawn the whole family-object.

Since I only need one instance on screen at a time, I also have set up "Destroy" right before the "Create"-Action,

While this seems to work ok, I'm not sure if this is the right way to do this... does anybody have another suggestion how to go about this?

Any help appreciated, thanks!
B
8
S
1
Posts: 3
Reputation: 643

Post » Thu Aug 01, 2013 9:19 am

I might be miss understanding the question you are asking, but the below tutorial helped me with random generating power ups. I hope this helps :)

Tutorial BurningWood2013-08-01 09:20:37
B
15
S
5
G
2
Posts: 164
Reputation: 3,082

Post » Thu Aug 01, 2013 10:18 am

[QUOTE=zhajym] Hi guys,

I have 6 different sprites set up in my layout and I'm trying create an instance from one of those (randomly selected) at a fixed timing rate. I have combined all of them in a family, but I only have the option to spawn the whole family-object.

Since I only need one instance on screen at a time, I also have set up "Destroy" right before the "Create"-Action,

While this seems to work ok, I'm not sure if this is the right way to do this... does anybody have another suggestion how to go about this?

Any help appreciated, thanks![/QUOTE]

Doing a 'Create Family' event will create random member of that family.
B
24
S
9
G
7
Posts: 756
Reputation: 7,292

Post » Fri Aug 02, 2013 3:43 pm

[QUOTE=vee41]
Doing a 'Create Family' event will create random member of that family.[/QUOTE]

Alright, wasn't sure if this would create instances of all objects in that family on top of each other. Couldn't really tell, because all my sprites have the same shape and size (just differing in color). But if it's only one random object, that's exactly what I wanted. Thanks! :)

@BurningWood:
Thanks for the link! Right now I was just looking for a way to spawn a random object, not to set a random position... But this tut also might come in handy for me soon. :)
B
8
S
1
Posts: 3
Reputation: 643


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 10 guests