A helper object to keep tilemap drawing performance decent across the new multi-camera system. Pretty much don't even have to think about this class unless you are doing some crazy hacking.
Constructor
new(tileWidth:Int, tileHeight:Int, widthInTiles:Int, heightInTiles:Int, ?camera:FlxCamera, scaleX:Float = 1.0, scaleY:Float = 1.0)
Instantiates a new camera-specific buffer for storing the visual tilemap data.
Parameters:
tileWidth | The width of the tiles in this tilemap. |
---|---|
tileHeight | The height of the tiles in this tilemap. |
widthInTiles | How many tiles wide the tilemap is. |
heightInTiles | How many tiles tall the tilemap is. |
camera | Which camera this buffer relates to. |
Variables
pixelPerfectRender:Null<Bool>
Whether or not the coordinates should be rounded during draw(), true by default (recommended for pixel art). Only affects tilesheet rendering and rendering using BitmapData.draw() in blitting. (copyPixels() only renders on whole pixels by nature). Causes draw() to be used if false, which is more expensive.
Methods
draw(camera:FlxCamera, flashPoint:Point, scaleX:Float = 1.0, scaleY:Float = 1.0):Void
Just stamps this buffer onto the specified camera at the specified location.
Parameters:
camera | Which camera to draw the buffer onto. |
---|---|
flashPoint | Where to draw the buffer at in camera coordinates. |
fill(color:FlxColor = FlxColor.TRANSPARENT):Void
Fill the buffer with the specified color. Default value is transparent.
Parameters:
color | What color to fill with, in 0xAARRGGBB hex format. |
---|
isDirty<Tile>(tilemap:FlxTypedTilemap<Tile>, camera:FlxCamera):Bool
Check if tilemap or camera has changed (scrolled, moved, resized or scaled) since the previous frame. If so, then it means that we need to redraw this buffer.
Parameters:
tilemap | Tilemap to check against. It's a tilemap this buffer belongs to. |
---|---|
camera | Camera to check against. It's a camera this buffer is used for drawing on. |
Returns:
The value of dirty flag.
isPixelPerfectRender(?camera:FlxCamera):Bool
Check if object is rendered pixel perfect on a specific camera.
resize(tileWidth:Int, tileHeight:Int, widthInTiles:Int, heightInTiles:Int, ?camera:FlxCamera, scaleX:Float = 1.0, scaleY:Float = 1.0):Void
Creates a bitmapData buffer from the tilemap's info.
Parameters:
tileWidth | The width of the tiles in this tilemap. |
---|---|
tileHeight | The height of the tiles in this tilemap. |
widthInTiles | How many tiles wide the tilemap is. |
heightInTiles | How many tiles tall the tilemap is. |
camera | Which camera this buffer relates to. |