
上QQ阅读APP看书,第一时间看更新
Time for action — detailing the OnCreate process
The OnCreate
method is the only method we can set into stone now. Cool!
- Set
UpdateRate
to60
frames per second.Method OnCreate:Int() SetUpdateRate(60)
- Now, read the dimensions of the canvas, your visible area. You will store this information inside the previously defined variables.
cWidth = DeviceWidth() cHeight = DeviceHeight()
- Before the method is closed, we will call a new method called
SetupGame
. In this method, we will set up the starting values of a new game. Putting this inside a method will enable us to call this part again, once the game is over.SetupGame() Return True End
- Now, create a new method called
SetupGame
. Some previously defined variable will be used and set to values appropriate for a new game.Method SetupGame:Int() totalBombsDestroyed = 0 levelNumber = 1 score = 0
- Later on, we will add some more stuff, but for now, we leave it like that. Close the method.
Return True End