Game Development Reference
In-Depth Information
if(rand%2) {
rightData = TYPE_CONVEX;
}
else {
rightData = TYPE_CONCAVE;
}
}
shapeID = ((topData << TOP_SIDE_BIT_SHIFT) |
(bottomData << BOTTOM_SIDE_BIT_SHIFT) |
(leftData << LEFT_SIDE_BIT_SHIFT) |
(rightData << RIGHT_SIDE_BIT_SHIFT));
shapeIDs[col][row] = shapeID;
}
}
return shapeIDs;
}
Once we have figured out the shapes that need to be applied to each piece, let's look
at the code that creates the final piece that we see on the screen.
To do this we make use of the copyPixel method available on Bitmapdata . The
description of the method quoted from Adobe's online documentation is as follows:
public function copyPixels(sourceBitmapData:BitmapData,
sourceRect:Rectangle, destPoint:Point, alphaBitmapData:BitmapData =
null, alphaPoint:Point = null, mergeAlpha:Boolean = false):void
Provides a fast routine to perform pixel manipulation between images with no
stretching, rotation, or color effects. This method copies a rectangular area of a
source image to a rectangular area of the same size at the destination point of the
destination BitmapData object .
If you include the alphaBitmap and alphaPoint parameters, you can use a
secondary image as an alpha source for the source image. If the source image has
alpha data, both sets of alpha data are used to composite pixels from the source
image to the destination image. The alphaPoint parameter is the point in the
alpha image that corresponds to the upper-left corner of the source rectangle. Any
pixels outside the intersection of the source image and alpha image are not copied to
the destination image .
The mergeAlpha property controls whether or not the alpha channel is used when
a transparent image is copied onto another transparent image. To copy pixels with
the alpha channel data, set the mergeAlpha property to true . By default, the
mergeAlpha property is false .
 
Search WWH ::




Custom Search