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 — enhancing the OnObjectTimer method

The OnObjectTimer method of the engine class needs to be detailed. For the bullets, the canShoot field of the game class needs to be set to TRUE and they also need to be deleted.

  1. Check whether the timer ID is equal to g.tmDelete. If yes, call the Remove method of the object.
    Method OnObjectTimer:Int(timerId:Int, obj:ftObject)
    If timerId = g.tmDelete Then obj.Remove()
    
  2. Check whether the timer ID is equal to g.canShoot. If yes, set g.canShoot to True.
    If timerId = g.tmCanShoot Then g.canShoot = True
    Return 0
    End
    

What just happened?

Enhancing the OnObjectTimer method will let you delete objects and set the canShoot field of the game class to True, so the enemy plane can spawn bullets again.

It is gone!—a ...

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