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 some engine particle FX

  1. Insert the SpawnPlayerEngine method into the game class.
    Method SpawnPlayerEngine:Int()
    
  2. Determine the position 20 pixels right behind the ship with the GetVector method.
    Local d:Float[] = player.GetVector(20,180.0+player.angle)
    
  3. Create a new object for the engine particle from the sprite atlas.
    obj = eng.CreateImage(atlas, 16,96,16,16, d[0],d[1])
    
  4. Set the angle to the ship angle, scale it down to a half, and set the layer to layerFX.
    obj.SetAngle(player.angle)
    obj.SetScale(0.5)
    obj.SetLayer(layerFX)
    
  5. To remove the trail after 100 milliseconds, call CreateObjTimer. After that, close that method.
    eng.CreateObjTimer(obj, tmObjRemove, 100)
    Return 0
    End
    

What just happened?

The method SpawnPlayerEngine creates ...

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