The clouds will come in different sizes and shapes. The shapes are chosen randomly from the sprite sheet by the method of creation, as follows:
1. Insert the method
CreateClouds
into thegame
class.Method CreateClouds:Int()
2. As we will be creating several clouds, create a local object variable.
Local obj:ftObject
3. To calculate the shape, add a local
shape
variable of the type FLOAT.Local shape:Float
4. Set the cloud layer as the default layer; all new objects, from now on, will be assigned to it.
eng.SetDefaultLayer(layerClouds)
5. We want ten clouds. Start a FOR loop ranging from
1
to10
.For Local i:Int = 1 To 10
6. To determine the cloud shape, we need a random number ranging from
0
to100
.shape = Rnd(100.0)
7. Check if
shape
is less or equal to20
. If yes, then load one cloud shape from the sprite atlas. Place it randomly on the canvas.If shape <= 20.0 Then obj = eng.CreateImage(atlas,128,0,64,64,Rnd(10,cw-10),Rnd(10,ch-10))
8. If
shape
is greater...