The method we have created to spawn smoke will be called once a plane gets hit. The more hits it takes, the higher the chance of emitting a smoke particle.
SpawnSmoke
inside the game
class. The parameters are the plane object and the number of hits.Method SpawnSmoke:Int(plane:ftObject, hits:Int)
0
to 100
will be greater than 100-hits
times 10
.If Rnd(0,100)>(100-hits*10) Then
layerGame
.eng.SetDefaultLayer(layerGame)
20
pixels and the angle is calculated randomly taking the hits into account.Local vec:Float[] = plane.GetVector(20,180+Rnd(-10*hits,10*hits),True)
x
offset for the next CreateImage
call from the sprite atlas. This is used to choose the smoke images randomly.Local xoff:Float = Int(Rnd(0,3))
Local obj := eng.CreateImage(atlas,144+xoff*16.0,64,16,16, vec[0],vec[1])
The smoke particles won't move, but the change in their alpha value over time means they will fade out.
0.1
, at a random time between 1000
and 3000
milliseconds. The transition ID will be triDelete
.Local trans:ftTrans = obj.CreateTransAlpha(0.1, Rnd(1000, 3000), False, triDelete)
0.1
to 0.5
.obj.SetScale(Rnd(0.1,0.5))
1.0
to 4.0
.obj.AddTransScale(trans, Rnd(1.0,4.0), False)
Return 0 End
You created a method that will let you emit smoke particles behind a plane, depending on how many hits that plane took.
3.17.162.214