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:
SELECT
statement with gameMode
as a parameter.Method OnUpdate:Int() Local d:Float = Float(eng.CalcDeltaTime())/60.0 If isSuspended = False Then Select gameMode
gameMode
is equal to gmPlay:
Case gmPlay eng.Update(d)
eng.CollisionCheck(layerGame)
TouchHit
method, do a touch check for the background layer:If TouchHit(0) Then eng.TouchCheck(layerBackGround) Endif
txtScore
object to the current score value:txtScore.SetText("Score: "+score)
gmMenu:
Case gmMenu
If TouchHit(0) Then eng.TouchCheck(layerTitle) Endif
gmGameOver
, update the background layer:Case gmGameOver eng.Update(layerBackGround, d) End Endif Return 0 End
With detailing the OnUpdate
method of the game
class, we have the general control set of our game. When the game is not suspended, we check for touch hits, and then which touchable object of fantomEngine was hit. We also update objects depending on which mode the game is in.
At this stage, the game will look like the following screenshot:
3.145.169.109