The OnUpdate
event is the place to update all game objects and control the flow of the game in general. You do everything in the method line-by-line and with hundreds of statements. However, we took the approach with building a lot of helper methods, which will now be called inside this method:
OnUpdate
method, store the result of a call to the method GetDeltaTime
in the local variable d
.Method OnUpdate:Int() Local d:Int = GetDeltaTime()
If
statement, whether the field isSuspended
is FALSE
.If isSuspended = False Then
Select
statement with the field gameMode
. Then, insert the Case
statement for the constant gmPlay
.Select gameMode Case gmPlay
Update
method of your engine instance. As a speed parameter, we use the local d
variable divided by 60
. The speed parameter is a FLOAT
value so you need to cast d
to FLOAT
.eng.Update(Float(d)/60.0)
TouchHit
for the first finger is reported. On HTML5, this also reports a click with the left mouse button.If TouchHit(0) Then
0
.score = 0
TouchCheck
for the game and background layers. This will test each touchable object in these layers, if the touch coordinates are within the borders of that object. If yes, it will call the engine's OnObjectTouch
method.eng.TouchCheck(layerGame) eng.TouchCheck(layerBackGround) Endif
Case
statement for the gmMenu
constant.Case gmMenu
TouchCheck
on the layerTitle
layer. It will basically check if the PLAY button was hit.If TouchHit(0) Then eng.TouchCheck(layerTitle) Endif
Select
statement and update the info text objects.End UpdateInfoText()
If
check.Endif Return 0 End
3.142.12.207