The method to emit explosion particles works in a similar way to the one that emits smoke.
1. Insert a method called
SpawnExplosion
in thegame
class. The parameters are thex
andy
positions, and the amount of particles to create.Method SpawnExplosion:Int(x:Float, y:Float, amount:Int)
2. Set the default layer to the game layer.
eng.SetDefaultLayer(layerGame)
3. Start a FOR loop for the local
i
variable ranging from1
to theamount
parameter of the method.For Local i:Int = 1 To amount
4. Determine a random
x
offset that is used when an image object for the explosion particle is created.Local xoff:Float = Int(Rnd(0,3))
5. Create a local object for the particle image. It will be placed at the coordinates given to the method.
Local obj:=eng.CreateImage(atlas,144+xoff*16.0,80,16,16, x,y)
6. Now, determine a random vector that will be
10
to40
pixels and at a random angle around the given coordinates of the method.Local vec:Float[] = obj.GetVector(Rnd(10...