Game Development Reference
In-Depth Information
This is an interesting function. Its job is to draw the player's ship as a vector shape and use the
BlitArrayAsset class to create an Array of 360 rotations for the ship. Each of those will be a
separate BitmapData object that will be used for blitting to the canvasBitmapData at render time.
Which one of the 360 is blitted is based on the rotation angle of the player ship.
We drew the player's ship in Adobe Fireworks (our favorite Bitmap tool) first; see Figure 11-4.
Then we used the bitmap graphic we created to plot out the lines on the drawCanvas shape
instance in the createPlayerShip .
Figure 11-4. The 32
32 player ship blown up in Fireworks design mode
The player ship's design is actually on a 32
32 pixel canvas in Fireworks, blown up sixteen
times its normal size in the design view. The blue line represents the place where the glow filter
will end, and the red line is a buffer area for rotation so drawing the object won't cause clipping.
All of our game objects will be drawn in the color white, and the global class-level
BlasterMines.as GlowFilter instance spriteGlowFilter will be changed as needed to the
correct color for the object's glow effect. The ship's glow is a blue color. When the game begins,
spriteGlowFilter is set to a blue color, so there is no need to change it here. We will reset it for
other objects, so we need to set the color before we draw those. Next, we draw vector lines in the
drawCanvas , and when finished, we use the BitmapData.draw method to draw the object into a
BitmapData holder. We then create the animationList array for the player with a temporary
BlitArrayAsset instance.
The shield for the player is created in a similar manner (with a drawCanvas.graphics.drawCircle
function call). It is drawn into a BitmapData instance ( shieldBitmapData ) and will be blitted to the
canvasBitmapData directly when the player's shield is turned on.
Now, we will examine the projectileManager.createProjectiles function:
Search WWH ::




Custom Search