Stopping an Every X Seconds..

  • 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

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Add an event: compare 2 variables

    enemies.Count < 10

    this will check if the total of enemies objects is lower then 10

  • 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.

  • enemies.count<1

    (sub event) for 1 to 10 : spawn enemies

    here you go - quick example capx (r161)

  • thx guys really appreciate the help :)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)