O'Reilly logo

Monkey Game Development by Michael Hartlef

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required