Game Development Reference
In-Depth Information
is provided. In Start() , we call InvokeRepeating() function and ask it to keep calling In-
crementScore() one time every second. As a result, the score will be incremented by 1
every second, and the 3D Text that displays the score updates continuously as well. When
OnAllLivesLost message is received, we know that the game is over. Therefore, we have to
stop incrementing score by stopping the repetitive calling of IncrementScore() . To stop call-
ing a function we use CancelInvoke() function and give it the name of the target function.
The final look of the game with lives and score counter is shown in Illustration 87. The
complete demo is available in scene21 in the accompanying project.
Search WWH ::




Custom Search