This method will reset all score fields, deactivate the title layer, spawn the planes, and deactivate possibly visible status messages. It also starts the playback of the engine sound.
1. Add a method called
StartNewGame
to thegame
class.Method StartNewGame:Int()
2. Seed the random number generator with the current value of a call to
Millisecs()
.Seed = Millisecs()
3. Reset both score fields.
score = 0 scoreC = 0
4. Deactivate the title layer.
layerTitle.SetActive(False)
5. Remove all existing objects on the game layer.
layerGame.RemoveAllObjects()
6. Set the default layer to be
layerGame
.eng.SetDefaultLayer(layerGame)
7. Spawn the player and the enemy plane.
SpawnPlayer() SpawnEnemy()
8. Set the game mode to
gmPlay
.gameMode = gmPlay
9. Deactivate the text objects that display whether or not you have won.
txtYouWin.SetActive(False) txtYouLoose.SetActive(False)
10. Start playing the engine sound, and then close this method.
sndEngine.Play() Return...