A good place is the OnLayerUpdate
callback method of the engine
class. Check if one of the scores is 5
or bigger, and then set the game mode and also display a message.
1. Check if the
score
field of the game class is5
or greater.Method OnLayerUpdate:Int(layer:ftLayer) If g.score >= 5 Then
2. If yes, the player won. Activate the
g.txtYouWin
text object.g.txtYouWin.SetActive(True)
3. Set the game mode to
g.gmGameOver
and stop the engine sound effect.g.gameMode = g.gmGameOver g.sndEngine.Stop()
4. If the player score is lower than
5
, check if the computer score is greater or equal to5
.Elseif g.scoreC >= 5 Then
5. If yes, the computer won. Display the You Lose message by activating the
g.txtYouLoose
object.g.txtYouLoose.SetActive(True)
6. Set the game mode to
g.gmGameOver
.g.gameMode = g.gmGameOver
7. Stop the engine sound effect. Then close the initial IF check.
g.sndEngine.Stop() Endif Return 0 End