Game Development Reference
In-Depth Information
need to be able to continually update the BitmapData in the pieces
after they
re cut up in order for a camera feed to be worthwhile.
public class SourceImageCamera extends Sprite implements
ISourceImage {
protected var _rows:int, _columns:int;
protected var _video:Video;
protected var _camera:Camera;
protected var _sourceBitmap:BitmapData;
protected var _pieceList:Vector. < BitmapData > ;
public function SourceImageCamera(width:int, height:int,
fps:int = 15) {
_camera = Camera.getCamera();
_video = new Video(width, height);
_camera.setMode(width, height, fps);
ll notice a number of similarities between this class and the
one for embedded images. In this version, we create variables to
store the number of rows and columns for later use, as well as
references to use with the Video and Camera classes. For more
information on using the Camera class, refer to Appendix A, which
can be found at . When this class is con-
structed, new Camera and Video objects are created to match the
desired dimensions and frame rate.
public function getImages(rows:int, columns:int, width:int = 0,
height:int = 0):Vector. < BitmapData > {
if (_pieceList) return _pieceList;
if (width == 0) width = _video.width;
if (height == 0) height = _video.height;
_rows = rows;
_columns = columns;
_sourceBitmap = new BitmapData(width, height);
_sourceBitmap.draw(_video, new Matrix());
var pieceBitmap:BitmapData;
var pieceWidth:int = Math.floor(_sourceBitmap.width /
var pieceHeight:int = Math.floor(_sourceBitmap.height /
_pieceList = new Vector. < BitmapData > ();
for (var j:int = 0; j < _rows; j++) {
for (var i:int = 0; i < _columns; i++) {
pieceBitmap = new BitmapData(pieceWidth,
Search Nedrilad ::

Custom Search