how do I add lives to my game?

Get help using Construct 2

Post » Sun Oct 30, 2011 12:24 am

how so I add lives to my game so that when a certain monster hits him he loses a banana(life)
also how do I make it to where when he jumps on a monster it kills it
B
2
G
1
Posts: 8
Reputation: 466

Post » Sun Oct 30, 2011 12:39 am

In my case I add a variable number set to 3 to the player sprite, then when he collide a monster I substract one to the variable.
I display hearts (bananas in your case)looking the variable.
B
23
S
5
G
5
Posts: 112
Reputation: 4,737

Post » Sun Oct 30, 2011 12:48 am

Regarding lives, I think the easiest way would be to assign a global variable ("lives" or "health") to your player object, and upon collision with an enemy, subtract 1 from that variable.

Then once "lives" reaches zero you can kill your player in any manner of ways.

An instance variable would also work, but would be more appropriate if you have multiple players, or would like to assign a certain amount of health to each enemy.

Jumping on a monster would be much easier with "overlapping at offset", but I don't think it's been implemented in C2 yet. I'd try comparing X and Y co-ordinates of the player in relation to the enemy to test if the player is on top of the enemy while colliding.

There's an example of another way to do it here.

edit: Here's how I would do it. linkplauk2011-10-30 01:16:55
B
28
S
7
G
7
Posts: 102
Reputation: 6,483


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 20 guests