Game Development Reference
In-Depth Information
camera.height=384;
camera.cols=12;
camera.rows=12;
camera.x=0;
camera.y=0;
camera.bufferBD=new BitmapData(camera.width+mapTileWidth,
camera.height+mapTileHeight,true,0x00000000);
camera.bufferRect=new Rectangle(0,0,camera.width,camera.height);
camera.bufferPoint=new Point(0,0);
tileRect=new Rectangle(0,0,mapTileWidth,mapTileHeight);
tilePoint=new Point(0,0);
//canvasBitmap
canvasBitmapData=new BitmapData(camera.width,camera.height,true,0x00000000);
canvasBitmap=new Bitmap(canvasBitmapData);
backgroundBitmapData = new BitmapData(camera.width, camera.height,
false, 0x000000);
backgroundBitmap = new Bitmap(backgroundBitmapData);
addChild(backgroundBitmap);
addChild(canvasBitmap);
//look ahead points
lookAheadPoints[0] = new LookAheadPoint(0, 0, this);
lookAheadPoints[1] = new LookAheadPoint(0, 0, this);
lookAheadPoints[2] = new LookAheadPoint(0, 0, this);
//to show look ahead points in development
lookAheadPoints[0].show();
lookAheadPoints[1].show();
lookAheadPoints[2].show();
}
Here is a detailed description of the main points of this function:
The camera is initialized by setting its width and height to be the viewable screen width
and height (384
384). The number of rows and columns are set to be the number of
rows and columns in the viewable area (12
12).
The camera.bufferBitmapData is initialized with a size that is one tile width and one tile
height greater than the canvas will be. This is how our smooth scrolling will work. If we
did not do this, we would only be able to scroll 32 pixels at a time, rather than the
smooth single pixel at a time needed for our game.
The camera.bufferRect and buffer.point instances are initialized. The bufferPoint will
always stay at 0,0 because it will start painting into the canvas at the same spot each
frame tick. The bufferRect 's width and height will always be 384 each, but the x and y
values will be between 0 and 31 to provide for our smooth scrolling in each direction.
Search WWH ::




Custom Search