class FlxTypedTilemap<Tile>
package flixel.tile
extends FlxBaseTilemap › FlxObject › FlxBasic
import flixel.tile.FlxTilemap
extended by FlxTilemap
This is a traditional tilemap display and collision class. It takes a string of comma-separated numbers and then associates those values with tiles from the sheet you pass in. It also includes some handy static parsers that can convert arrays or images into strings that can be loaded.
Static variables
staticdefaultFramePadding:Int = 2
The default frame padding tilemaps will use when their own framePadding
is not set
5.0.0
.See also:
FlxTypedTilemap.framePadding
Variables
antialiasing:Bool = FlxSprite.defaultAntialiasing
Controls whether the object is smoothed when rotated, affects performance.
4.1.0
.See also:
FlxSprite.defaultAntialiasing
blend:BlendMode = null
Blending modes, just like Photoshop or whatever, e.g. "multiply", "screen", etc.
color:FlxColor = 0xffffff
Tints the whole sprite to a color (0xRRGGBB format) - similar to OpenGL vertex colors. You can use 0xAARRGGBB colors, but the alpha value will simply be ignored. To change the opacity use alpha.
framePadding:Null<Int> = null
Eliminates tearing on tilemaps by extruding each tile frame's edge out by the specified
number of pixels. Ignored if <= 0. If null
, defaultFramePadding
is used
Note: Changing this only affects future loadMap calls.
5.4.0
.See also:
FlxTypedTilemap.defaultFramePadding
read onlyoffset:FlxPoint = FlxPoint.get()
Use to offset the drawing position of the tilemap, just like FlxSprite.
read onlyscale:FlxPoint
Changes the size of this tilemap. Default is (1, 1). Anything other than the default is very slow with blitting!
Methods
follow(?camera:FlxCamera, border:Int = 0, updateWorld:Bool = true):Void
Call this function to lock the automatic camera to the map's edges.
Parameters:
camera | Specify which game camera you want. If null getScreenPosition() will just grab the first global camera. |
---|---|
border | Adjusts the camera follow boundary by whatever number of tiles you specify here. Handy for blocking off deadends that are offscreen, etc. Use a negative number to add padding instead of hiding the edges. |
updateWorld | Whether to update the collision system's world size, default value is true. |
getBounds(?bounds:FlxRect):FlxRect
Get the world coordinates and size of the entire tilemap as a FlxRect.
Parameters:
bounds | Optional, pass in a pre-existing FlxRect to prevent instantiation of a new object. |
---|
Returns:
A FlxRect containing the world coordinates and size of the entire tilemap.
getTileCoords(index:Int, midpoint:Bool = true):Array<FlxPoint>
Returns a new array full of every coordinate of the requested tile type.
Parameters:
index | The requested tile type. |
---|---|
midpoint | Whether to return the coordinates of the tile midpoint, or upper left corner. Default is true, return midpoint. |
Returns:
An Array with a list of all the coordinates of that tile type.
isOnScreen(?camera:FlxCamera):Bool
Check and see if this object is currently on screen. Differs from FlxObject
's implementation
in that it takes the actual graphic into account, not just the hitbox or bounding box or whatever.
Parameters:
camera | Specify which game camera you want. If |
---|
Returns:
Whether the object is on screen or not.
overlapsWithCallback(object:FlxObject, ?callback:(FlxObject, FlxObject) ‑> Bool, flipCallbackParams:Bool = false, ?position:FlxPoint):Bool
Checks if the Object overlaps any tiles with any collision flags set, and calls the specified callback function (if there is one). Also calls the tile's registered callback if the filter matches.
Parameters:
object | The FlxObject you are checking for overlaps against. |
---|---|
callback | An optional function that takes the form |
flipCallbackParams | Used to preserve A-B list ordering from |
position | Optional, specify a custom position for the tilemap (used for |
Returns:
Whether there were overlaps, and the result of the callback, if one was specified.
ray(start:FlxPoint, end:FlxPoint, ?result:FlxPoint):Bool
Shoots a ray from the start point to the end point.
If/when it passes through a tile, it stores that point and returns false.
Note: In flixel 5.0.0, this was redone, the old method is now rayStep
Parameters:
start | The world coordinates of the start of the ray. |
---|---|
end | The world coordinates of the end of the ray. |
result | Optional result vector, to avoid creating a new instance to be returned. Only returned if the line enters the rect. |
Returns:
Returns true if the ray made it from Start to End without hitting anything. Returns false and fills Result if a tile was hit.
rayStep(start:FlxPoint, end:FlxPoint, ?result:FlxPoint, resolution:Float = 1):Bool
Shoots a ray from the start point to the end point.
If/when it passes through a tile, it stores that point and returns false.
This method checks at steps and can miss, for better results use ray()
Parameters:
start | The world coordinates of the start of the ray. |
---|---|
end | The world coordinates of the end of the ray. |
result | Optional result vector, to avoid creating a new instance to be returned. |
resolution | Defaults to 1, meaning check every tile or so. Higher means more checks! Only returned if the line enters the rect. |
Returns:
Returns true if the ray made it from Start to End without hitting anything. Returns false and fills Result if a tile was hit.
5.0.0
.setDirty(dirty:Bool = true):Void
Set the dirty flag on all the tilemap buffers. Basically forces a reset of the drawn tilemaps, even if it wasn't necessary.
Parameters:
dirty | Whether to flag the tilemap buffers as dirty or not. |
---|
tileToSprite(tileX:Int, tileY:Int, newTile:Int = 0, ?spriteFactory:FlxTileProperties ‑> FlxSprite):FlxSprite
Change a particular tile to FlxSprite. Or just copy the graphic if you dont want any changes to map data itself.
Parameters:
tileX | The X coordinate of the tile (in tiles, not pixels). |
---|---|
tileY | The Y coordinate of the tile (in tiles, not pixels). |
newTile | New tile for the map data. Use -1 if you dont want any changes. Default = 0 (empty) |
spriteFactory | Method for converting FlxTile to FlxSprite. If null then will be used defaultTileToSprite() method. |
Returns:
FlxSprite.
updateBuffers():Void
Use this method so the tilemap buffers are updated, e.g. when resizing your game