The OnUpdate
method will be called in the amount you have set the update rate to. The base script sets it to 60
times. Follow the given steps:
1. Start a
SELECT
statement withgameMode
as a parameter.Method OnUpdate:Int() Local d:Float = Float(eng.CalcDeltaTime())/60.0 If isSuspended = False Then Select gameMode
2. First, check if
gameMode
is equal togmPlay:
Case gmPlay eng.Update(d)
3. Start a collision check for the game layer:
eng.CollisionCheck(layerGame)
4. Next, if there is a
TouchHit
method, do a touch check for the background layer:If TouchHit(0) Then eng.TouchCheck(layerBackGround) Endif
5. Set the text property of the
txtScore
object to the current score value:txtScore.SetText("Score: "+score)
6. Now, check whether the game mode is set to
gmMenu:
Case gmMenu
7. If there is a touch hit, perform a touch check for the title layer:
If TouchHit(0) Then eng.TouchCheck(layerTitle) Endif
8. If the game mode is set to
gmGameOver
, update the...