How do I keep count of how may enemys..

Get help using Construct 2

Post » Thu Aug 07, 2014 1:57 am

I need to keep count of how many enemy's spawned on the layout and once it meets the limit it will stop spawning them in order for the level to be complete.

Example: once an enemy is killed I am creating a new enemy at a random spot, but I want the spawning to stop once it reaches 25 enemy's.

Any idea how I can make this happen, I already have the condition that once 25 enemys are killed it ends the level but I want there to be no enemy's on screen when the end of the level is reached.

Any help would be appreciated!
B
5
S
2
Posts: 105
Reputation: 837

Post » Thu Aug 07, 2014 2:44 am

use a variable. Have it count up every time an enemy is spawned. when it hits 25 stop spawning.
when it hits 25 and they're all dead, end the level.

Will that work for ya?
B
88
S
43
G
71
Posts: 601
Reputation: 43,669

Post » Thu Aug 07, 2014 3:05 am

Might be able to add the condition to only spawn if System: sprite.Count < 25
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Thu Aug 07, 2014 3:32 am

Thanks for the quick replys! ye I think both answers will work thanks a lot!
B
5
S
2
Posts: 105
Reputation: 837

Post » Fri Aug 08, 2014 1:20 am

codah wrote:Might be able to add the condition to only spawn if System: sprite.Count < 25


I tried doing this but cant get it to work correctly, I don't think I did it right:

I have System- Enemy on destroyed - create enemy at (x,y)
System- Enemies < Enemy.count

Enemies is the Variable and Enemy is the Sprite name, have I done this wrong?
B
5
S
2
Posts: 105
Reputation: 837

Post » Fri Aug 08, 2014 2:31 am

If you're destroying an enemy and then spawning another one, enemy.count will never change.

example: say there's 3 enemies, so enemy.count = 3. you kill one. enemy.count goes down to 2. another is spawned. enemy.count goes right back to 3.
B
88
S
43
G
71
Posts: 601
Reputation: 43,669

Post » Fri Aug 08, 2014 3:12 am

Enemy on destroyed
Enemies < 25

THEN
create enemy
add 1 to enemies

Enemies = 25
enemy.count = 0

THEN
next level

how's that?
B
88
S
43
G
71
Posts: 601
Reputation: 43,669

Post » Fri Aug 08, 2014 9:10 am

you could do like this
You do not have the required permissions to view the files attached to this post.
B
257
S
42
G
15
Posts: 1,992
Reputation: 41,435

Post » Fri Aug 08, 2014 10:00 am

Using lordshiva1948 demo here is another way.

use the sprite.count as spacedoubt says
You do not have the required permissions to view the files attached to this post.
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,728

Post » Fri Aug 08, 2014 2:44 pm

Wow thanks for all the reply's, ill try these suggestions now :) much appreciated!
B
5
S
2
Posts: 105
Reputation: 837

Next

Return to How do I....?

Who is online

Users browsing this forum: gameba and 8 guests