How do I Stop Construct 2 from being confused?

Get help using Construct 2

Post » Thu Feb 26, 2015 5:08 pm

So this problem I thought I solved but apparently not.

I have a global variable which tracks how many Bad guys are on screen. Now these are in a family with a local variable of health that is set to 1. The player can hit them and take health off, when it takes the health to 0 it destroys the enemy and lowers the enemy count Variable by 1. The problem is, if the player hits 2 enemies at EXACTLY the same time, it treats it as if only 1 has been destroyed, does anyone know the cause of this?

Thanks so much
Joel
B
7
S
1
Posts: 61
Reputation: 567

Post » Thu Feb 26, 2015 5:24 pm

You could create an event that subtracts 1 from your variable every time an enemy gets destroyed.

Something like this: [[Enemy] On Destroyed] : |Subtract 1 from Global variable|
B
11
S
3
G
1
Posts: 91
Reputation: 997

Post » Thu Feb 26, 2015 7:38 pm

you should compare. enemyname.count that will give you the amount of enemies
B
42
S
17
G
2
Posts: 850
Reputation: 6,209

Post » Thu Feb 26, 2015 7:41 pm

Oh right. Excellent reply @Volkiller730 :)
B
11
S
3
G
1
Posts: 91
Reputation: 997

Post » Thu Feb 26, 2015 8:26 pm

@BouncyTrip ,@volkiller730

Thank you both for your replys. Unfortunately I already have the enemy count stored in a variable but when two of the enemy instance are destroyed at the same time it only counts one as being destroyed. Both of their sprites are destroyed but the .count only takes 1 away. And again annoyingly my game requires the player to destroy all the enemy's to progress, this leaves the problem of both sprites being destroyed but the game thinking there is still a single enemy left. If that makes sense ha!

Joel
B
7
S
1
Posts: 61
Reputation: 567

Post » Thu Feb 26, 2015 9:16 pm

How is that possible? Enemyname.count is a specific system expression that gives you the value of the actual number of "enemy" sprites on your layout... Can you submit a .capx?
B
11
S
3
G
1
Posts: 91
Reputation: 997

Post » Mon Jul 24, 2017 10:33 am

I have the same problem.

I made a global variable named EnemyCounter, and also made a global variable named Score.
Every time when an enemy object is created it adds 1 to EnemyCounter, and when an enemy object is destroyed it subtracts 1 from EnemyCounter and adds 30 (for example) points to Score, but when 2 (or maybe more) enemy is destroyed at the same time, it still subtracts 1 from EnemyCounter and adds 30 points to Score instead of subtracting 2 from EnemyCounter and adding 60 points to Score.

Is there any solution?
B
4
Posts: 9
Reputation: 218

Post » Mon Jul 24, 2017 10:54 am

B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Mon Jul 24, 2017 2:12 pm



I can't open these project files. It says they are from a newer version of Construct 2. I have the latest stable version.
Although, I just applied the .count version on counting the enemies and it seems working, but I still don't know how to add points to Score without the "on destroyed" event.
B
4
Posts: 9
Reputation: 218

Post » Mon Jul 24, 2017 3:17 pm

Up to you.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950


Return to How do I....?

Who is online

Users browsing this forum: dop2000 and 7 guests