For this, we need to detail the OnLayerTransition
method of the engine
class, as follows:
g.tidNextLevel
.Method OnLayerTransition:Int(transId:Int, obj:ftLayer) If transId = g.tidNextLevel Then
1.0
. That means it would be fully visible.g.layerGame.SetAlpha(1.0)
4
(we have only four levels).If g.levelNum < 4 Then
g.levelNum+=1 g.LoadLevel()
g.gmPlay
.g.gameMode = g.gmPlay
Else g.layerTitle.SetActive(True)
g.gmMenu
and close off the two If
checks.g.gameMode = g.gmMenu Endif Endif Return 0 End
We have detailed the OnLayerTransition
method of the engine class. We can now switch to a new level or jump back to the title layer when the last level has been finished.
That is all for now. We have a running game with most elements present. We can switch to new levels and control the player and the winning conditions.
There are a few things left for you to do, and the next part will tell you what they are.
Some parts in this game were left out on purpose for you to implement on your own. For example, sounds. While the machine is moving, you can play back some nice heavy machinery sounds. You could also add sounds for when a crate hits a target or you bump into a wall.
Another thing to add is some kind of high-score mechanism. Give points based on how fast the player finishes a level. For this, you need to measure time. Another neat gimmick would be that if you bump the machine too many times into a wall, it breaks and the player loses.
You see, there is still enough room for you to enhance the game.
18.189.188.238