Time for action — modifying the OnSuspend event

The OnSuspend method will be called from Monkey, when the app is not completely ended from the operation system and still runs in the background:

  1. Inside the OnSuspend method, set isSuspended to TRUE.
    Method OnSuspend:Int()
    isSuspended = True
    
  2. Since we don't need to update the game so quickly now, set the update rate to 5. This might conserve battery power.
    SetUpdateRate(5)
    Return 0
    End
    

What just happened?

Inside the OnSuspend event, we have set the isSuspended field to False, so we can act on it during the OnUpdate event. At the same time, we set the update rate to 5 FPS. This might conserve battery power, as the CPU doesn't need to update the game that often.

Another thing you might like to do is to save the state of the game.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.227.134.133