How do I spawn a boss after a certain kill count?

Get help using Construct 2

Post » Thu Sep 03, 2015 4:29 am

I'm trying to spawn a boss after a certain kill count (in this case 20). I created a bossSpawner object that should spawn a boss after 20 kills (global variable numEnemies). The problem I have is that the bossSpawner object spawn multiples sprites of the boss object instead of just one. Any suggestions on how to fix the problem? Please see my code below. Thanks in advance.

Image
B
28
S
11
G
15
Posts: 47
Reputation: 9,533

Post » Thu Sep 03, 2015 4:53 am

Message: Solomon can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
Look in this thread: https:// www.scirra.com/forum/viewtopic.php?f=147&t=153201
Brick by brick, stone by stone.
B
52
S
24
G
17
Posts: 273
Reputation: 12,663

Post » Thu Sep 03, 2015 5:33 am

Basic problem is that the condition "numEnemies = 20" is true on every tick, and boss is spawned every tick as long as numEnemies is 20. Many ways to solve this, and you can use any of these you like:

- Add "Trigger once" condition to your event after numEnemies = 20 condition.

- Add 1 to numEnemies after spawning the boss (then numEnemies is 21 and not 20).

- Add new global variable "BossSpawned" with initial value 0. Add condition BossSpawned = 0 to your event. Set BossSpawned to 1 after spawning.

- You can add second condition using "count" expression so that Boss is not spawned is there is more than 0 instances of boss. (I haven't used "count". So I'm not sure about this.)
Lokkim Games: Constructor Dude - Fun platformer game, PuzCro - Difficult puzzle game demo
B
9
S
3
G
1
Posts: 38
Reputation: 795

Post » Thu Sep 03, 2015 3:37 pm

@lumik, Thank you so much. It worked out.
B
28
S
11
G
15
Posts: 47
Reputation: 9,533


Return to How do I....?

Who is online

Users browsing this forum: Exabot [Bot] and 6 guests