Problems with Lives

Get help using Construct 2

Post » Thu May 09, 2013 2:15 pm

Guys, I'm having a lot of headache trying to get rid of an annoying bug that is happening with the lives system of my game.

So I'm here humbly asking for your help! q.q

The player sprite have a boolean that sets when it dies. This boolean is activated everytime player sprite touches an enemy sprite.

The boolean activated triggers a death event, that substracts 1 from a global variable "Lives"

and there is an game over event, triggered when the global variable "Lives" equals zero.

the "vulnerable" boolean is used to make the player invulnerable when it is carrying eggs





Now here's the problem, sometimes, when 2 enemies touch the player at the same time, or when a enemy touches the player twice (for example, touches it when jumping and once again when falling), 2 lives are substracted instead of one. Also, sometimes, if this happens when you have 1 life left, it starts counting negative, instead of 0, for consequence the player gets stuck at the stage.

I tried to disable the collision at the moment player touches an enemy, but still, the problem persists.


Any ideas about how to solve this? I'm getting crazy with it! (??)?? ???pcfernandesjr2013-05-09 14:17:04
B
12
S
6
G
3
Posts: 100
Reputation: 3,836

Post » Thu May 09, 2013 2:20 pm

Um...I guess one thing you could try is putting an "else" event on top of all the blocks following the first collision.

Basically that will force the program to read like this "did he collide with this guy? no, then how about this guy" instead of "he collided with this and this and this"
At least that's how I understand it.Sushin2013-05-09 14:22:52
B
10
S
3
G
3
Posts: 234
Reputation: 3,467

Post » Thu May 09, 2013 8:45 pm

Used "Trigger only once" at the Death event. It seems like it's solved.
B
12
S
6
G
3
Posts: 100
Reputation: 3,836

Post » Thu May 09, 2013 11:00 pm

You should also change lives = 0 to lives <= 0. It's more robust that way - in case the lives variable ever goes negative for any reason, you'll be covered.
B
17
S
4
G
4
Posts: 143
Reputation: 4,004


Return to How do I....?

Who is online

Users browsing this forum: BinaryPanda, MarkThomas and 19 guests