Stopping an Every X Seconds..

Get help using Construct 2

Post » Thu Feb 13, 2014 6:09 pm

Hey guys here is my problem,

I want my enemies to spawn 10 at a time, this works, and when there are 10 on the screen it stops, this also works.

However I then want to stop it spawning until all 10 on the screen have been destroyed, at the moment when one is destroyed the variable is then less than 10 so the program spawns another 10.
My code is as below,

Any help appreciated,

System: Enemy Amount<10

System: Every EnemySpawnTime Seconds - Enemy Spawner - Spawn Enemy
                                        Add 1 to EnemyAmount

B
2
Posts: 9
Reputation: 193

Post » Thu Feb 13, 2014 6:14 pm

Add an event: compare 2 variables

enemies.Count < 10

this will check if the total of enemies objects is lower then 10
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,592

Post » Thu Feb 13, 2014 7:00 pm

I would make a group that is responsible for creating 10 enemies and set it to inactive. The group when activated would spawn 10 enemies and then set itself to inactive. Every time an enemy is destroyed (on object destroyed) I would subtract 1 from enemy_count and then check if enemy_count = 0. If it does then enemies_spawn_10 group needs to be activated. You could also wrap the group up in a function and call it instead (passing it a parameter indicating how many enemies you need spawned). This would allow you to have multiple events that can spawn enemies in any number meaning you don't have to write a bunch of similar code.
Image
B
33
S
11
G
2
Posts: 564
Reputation: 5,173

Post » Thu Feb 13, 2014 8:50 pm

enemies.count<1
(sub event) for 1 to 10 : spawn enemies




here you go - quick example capx (r161)RamPackWobble2014-02-13 21:05:23
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
34
G
47
Posts: 1,194
Reputation: 30,892

Post » Mon Feb 17, 2014 4:35 pm

thx guys really appreciate the help :)
B
2
Posts: 9
Reputation: 193


Return to How do I....?

Who is online

Users browsing this forum: repkino and 6 guests