How do I spawn a lot of enemies

Just started using Construct 2? Post your questions here

Post » Mon Nov 23, 2015 8:17 pm

Hey guys,

I am working at a game where a lot of enemie's are spawn from the top of the layout (out of another object) but i am not sure how to do it. I know how to spawn an object out of another object but in this case it is kinda more complicated.

I have some enemies and i want them to be spawn in a certain order at a certain time (so not at random) during a level. i also do not want them to fall down all at the same timing (like every 2 seconds or so) and also not in the same order.

Is there a best way to do this in construct 2? maybe with an array or something?

I hope i don't have to build a thousand lines in my event sheet :-P

It is kinda difficult to explain, i hope you understand what i mean.

Thanks, Manny
B
5
Posts: 17
Reputation: 259

Post » Tue Nov 24, 2015 1:07 pm

It would be easier to answer your question if you told more about what you do want instead of what you don't..
What is the setup you are using right now, what kind of timing would you like?

If you don't want random, you could use a timer and/or condition based spawning..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Nov 24, 2015 8:49 pm

Well, i have a couple ob object at the top of my layout to spawn objects. These are enemies that you need to hit (touch) to kill them en friends you need to avoid hitting. Let's say i have 4 types of enemie sprites and 4 types of friend sprites.

These have all the physics behaviors so they will fall down from the top till the bottom (and then gets destroyed outside the layout)

Now i want the enemies and friends all to fall down in a certain order (like enemy 1, 3, 2, 1, 4, 2 etc).

Yes a timer is a possibility but can i let some objects fall down at different timing, like the first object falls after 2 seconds and then the next after 1 and then the next after 3 etc?

I can do it random but i want the level to be the same every time you'll open it up again.

I'll hope you'll understand what i mean.

Thanks for your time and response ;)
B
5
Posts: 17
Reputation: 259

Post » Tue Nov 24, 2015 9:15 pm

With a timer you can time things, so yes, the time can be different..

if you want an order of things to fall, you could just do it with a textvariable

"1;5;3;4;2;1;5;4:3"

set nextspawn to int(tokenat(textvariable,0,";")
set textvariable to right(textvariable,2*tokencount(textvariable)-1)

I guess you could do timing intervals in exactly the same way..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Nov 30, 2015 5:20 pm

i'm sorry but i can't figure out how that works in construct 2.

Can you tell me which event i need to get nextspawn and where i can fill in my textvariable?

I know to give my enemy/friend objects a variable name/value, but not how to call them in a specific order.
B
5
Posts: 17
Reputation: 259

Post » Mon Nov 30, 2015 6:20 pm

When you create a variable, you can set it's value inside the editor.
You could also create an action to set the variable.

I don't know which conditions you need for your event so I'd have to guess..
something like:

on timer
(subevent)
if nextspawn = 1
> create enemy1
if nextspawn = 2
> create enemy 2
(empty)
>set nextspawn to int(tokenat(textvariable,0,";")
-set textvariable to right(textvariable,2*tokencount(textvariable)-1)
-start timer for random(1,4)
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 1 guest