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 — spawning a particle emitter

The only task of this class will be to create a new emitter and add it to the emitter list of our game class:

  1. Add a new method called SpawnEmitter to the game class. Its parameters are the position, a time factor, and the kind flag.
    Method SpawnEmitter:Int (x:Float,y:Float,t:Float,k:Int=0)
    
  2. Add a new instance of the ParticleEmitter class to the emitterList. Then, close this method:
    emitterList.AddLast(New ParticleEmitter(x,y,t,k))
    Return 0
    End
    

What just happened?

Now, we are able to create emitters whenever and wherever we want. They will spit out particles for as long as we tell them to. Updating the emitters will be done inside the heart of our game, the engine class.

When you spawn particles later in ...

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