How to write the game logic of character lives count?

I saw the game demo : BatchBuild and iPhoneMatch

They have a timer count down and score.

In my game, I want to assign the character with 3 lives.

When the character hit an object and die, it will reduce one life and return to the start of the game scene.

Is there any character die() API to call it and reduce it’s lives count?

How should I code this game logic?

In the same level:
public static int lives = 0;

In different levels:
PlayerPrefs.SetInt(“lives”,0);

if(PlayerPrefs.GetInt(“lives”)>=3)
//gameover

May I ask is there a javascript version to declare, set and get a global variable?

Can your code

public static int lives = 0; 

In different levels: 
PlayerPrefs.SetInt("lives",0); 

if(PlayerPrefs.GetInt("lives")>=3)

change to js?
[/code]

Some cool videos here. Check out #13 for lives.

Thanks for great video reference!