Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

8. Game #7, Air Dogs 1942 > Time for action — creating the explosion

Time for action — creating the explosion

The method to emit explosion particles works in a similar way to the one that emits smoke.

  1. Insert a method called SpawnExplosion in the game class. The parameters are the x and y 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 from 1 to the amount 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)
    

  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint