Updating the HUD with lives remaining
In the previous section, we modified the CucumberManManager
script to track the number of lives our player has remaining and, when none were left, the appropriate animation was played. In this section, we will continue modifying the CucumberManManager
script to update the HUD with the number of lives remaining.
We only need to modify the CucumberManManager
script's Update()
method. The completed Update()
method is provided here with an explanation of the changes made:
voidUpdate(){ if(collectingCherries){ if(tempCurrentCherryCount></span>=60){ currentCherryCount=currentCherryCount+1; tempCurrentCherryCount=0; _ptsManager=GameObject.Find ("Score_Value").GetComponent<PointsManager>(); PointsManager.currentScore= PointsManager.currentScore+5; }else{ tempCurrentCherryCount=tempCurrentCherryCount+1; } } if(livesRemaining==2){ Destroy(GameObject.Find("Life3")); } if(livesRemaining==1){ Destroy(GameObject...