1
Support / Re: Help with Lives System
« on: September 21, 2013, 04:25:26 pm »
It's probaby easier to use the tk2dTextMesh to display the score. In the hierarchy create a tk2dUITextMesh object then drag it to the livesMesh slot on the script. Depending on your camera settings you may have to change the scale of the text mesh so it is visible.
Code: [Select]
using UnityEngine;
using System.Collections;
public class Lives : MonoBehaviour
{
public int startingLives = 3;
public static int curLives;
public tk2dTextMesh livesMesh;
void Start ()
{
curLives = startingLives;
livesMesh.text = "Lives: " + curLives.ToString();
livesMesh.Commit();
}
void OnLevelWasLoaded(int level)
{
if (level == 08)
{
if (Score.score < 1500)
{
curLives--;
livesMesh.text = "Lives: " + curLives.ToString();
livesMesh.Commit();
}
if (curLives < 0)
{
print ("Game Over!");
livesMesh.text = "Game Over!" + curLives.ToString();
livesMesh.Commit ();
}
}
}
}