1. Insert the
SpawnPlayerEngine
method into thegame
class.Method SpawnPlayerEngine:Int()
2. Determine the position
20
pixels right behind the ship with theGetVector
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, callCreateObjTimer
. After that, close that method.eng.CreateObjTimer(obj, tmObjRemove, 100) Return 0 End
The method SpawnPlayerEngine
creates a nice particle effect that reassembles the thrust of an engine. It also creates a timer for each particle so it will be removed after its lifetime.