class FlxBaseTilemap<Tile>
package flixel.tile
extends FlxObject › FlxBasic
extended by FlxTypedTilemap
Variables
auto:FlxTilemapAutoTiling = OFF
Set this flag to use one of the 16-tile binary auto-tile algorithms (OFF, AUTO, or ALT).
customTileRemap:Array<Int>
Set this to create your own image index remapper, so you can create your own tile layouts. Mostly useful in combination with the auto-tilers.
Normally, each tile's value in _data corresponds to the index of a tile frame in the tilesheet. With this active, each value in _data is a lookup value to that index in customTileRemap.
Example: customTileRemap = [10,9,8,7,6] means: 0=10, 1=9, 2=8, 3=7, 4=6
Methods
calcRayEntry(start:FlxPoint, end:FlxPoint, ?result:FlxPoint):Null<FlxPoint>
Calculates at which point where the given line, from start to end, first enters the tilemap. If the line starts inside the tilemap, a copy of start is returned. If the line never enters the tilemap, null is returned.
Note: If a result vector is supplied and the line is outside the tilemap, null is returned and the supplied result is unchanged
Parameters:
start | The start of the line |
---|---|
end | The end of the line |
result | Optional result vector, to avoid creating a new instance to be returned. Only returned if the line enters the tilemap. |
Returns:
The point of entry of the line into the tilemap, if possible.
5.0.0
.inlinecalcRayExit(start:FlxPoint, end:FlxPoint, ?result:FlxPoint):Null<FlxPoint>
Calculates at which point where the given line, from start to end, was last inside the tilemap. If the line ends inside the tilemap, a copy of end is returned. If the line is never inside the tilemap, null is returned.
Note: If a result vector is supplied and the line is outside the tilemap, null is returned and the supplied result is unchanged
Parameters:
start | The start of the line |
---|---|
end | The end of the line |
result | Optional result vector, to avoid creating a new instance to be returned. Only returned if the line enters the tilemap. |
Returns:
The point of exit of the line from the tilemap, if possible.
5.0.0
.inlinecolumnExists(column:Int):Bool
Whether a row exists at the given map location
Parameters:
column | The grid X location, in tiles |
---|
5.9.0
.inlinecolumnExistsAt(worldX:Float):Bool
Whether a column exists at the given map location
Parameters:
worldX | An X coordinate in the world |
---|
5.9.0
.computePathData(startIndex:Int, endIndex:Int, diagonalPolicy:FlxTilemapDiagonalPolicy = WIDE, stopOnEnd:Bool = true):FlxPathfinderData
Pathfinding helper function, floods a grid with distance information until it finds the end point. Note: Currently this process does NOT use any kind of fancy heuristic! It's pretty brute.
Parameters:
startIndex | The starting tile's map index. |
---|---|
endIndex | The ending tile's map index. |
policy | Decides how to move and evaluate the paths for comparison. |
stopOnEnd | Whether to stop at the end or not (default true) |
Returns:
An array of FlxPoint nodes. If the end tile could not be found, then a null Array is returned instead.
5.0.0
.computePathDistance(startIndex:Int, endIndex:Int, diagonalPolicy:FlxTilemapDiagonalPolicy = WIDE, stopOnEnd:Bool = true):Array<Int>
Pathfinding helper function, floods a grid with distance information until it finds the end point. Note: Currently this process does NOT use any kind of fancy heuristic! It's pretty brute.
Parameters:
startIndex | The starting tile's map index. |
---|---|
endIndex | The ending tile's map index. |
diagonalPolicy | How to treat diagonal movement. |
stopOnEnd | Whether to stop at the end or not (default true) |
Returns:
An array of FlxPoint nodes. If the end tile could not be found, then a null Array is returned instead.
inlinefindPath(start:FlxPoint, end:FlxPoint, simplify:FlxPathSimplifier = LINE, diagonalPolicy:FlxTilemapDiagonalPolicy = WIDE):Array<FlxPoint>
Find a path through the tilemap. Any tile with any collision flags set is treated as impassable. If no path is discovered then a null reference is returned.
Parameters:
start | The start point in world coordinates. |
---|---|
end | The end point in world coordinates. |
simplify | Whether to run a basic simplification algorithm over the path data, removing extra points that are on the same line. Default value is true. |
raySimplify | Whether to run an extra raycasting simplification algorithm over the remaining path data. This can result in some close corners being cut, and should be used with care if at all (yet). Default value is false. |
diagonalPolicy | How to treat diagonal movement. (Default is WIDE, count +1 tile for diagonal movement) |
Returns:
An Array of FlxPoints, containing all waypoints from the start to the end. If no path could be found, then a null reference is returned.
inlinefindPathCustom(pathfinder:FlxPathfinder, start:FlxPoint, end:FlxPoint, simplify:FlxPathSimplifier = LINE):Array<FlxPoint>
Find a path through the tilemap. Any tile with any collision flags set is treated as impassable. If no path is discovered then a null reference is returned.
Parameters:
pathfinder | Decides how to move and evaluate the paths for comparison. |
---|---|
start | The start point in world coordinates. |
end | The end point in world coordinates. |
simplify | Whether to run a basic simplification algorithm over the path data, removing extra points that are on the same line. Default value is true. |
raySimplify | Whether to run an extra raycasting simplification algorithm over the remaining path data. This can result in some close corners being cut, and should be used with care if at all (yet). Default value is false. |
Returns:
An Array of FlxPoints, containing all waypoints from the start to the end. If no path could be found, then a null reference is returned.
5.0.0
.forEachMapIndex(tileIndex:Int, f:(mapIndex:Int) ‑> Void):Void
Calls the desired function with every mapIndex
that uses the given tileIndex
Parameters:
tileIndex | The desired tile type |
---|---|
function | The function called with each mapIndex |
5.9.0
.forEachOverlappingTile(object:FlxObject, func:(tile:Tile) ‑> Void, ?position:FlxPoint):Bool
Calls the given function on ever tile that is overlapping the target object
Parameters:
object | The object |
---|---|
filter | Function that takes a tile and returns whether is satisfies the disired condition |
position | Optional, specify a custom position for the tilemap |
Returns:
Whether any overlapping tile was found
5.9.0
.getAllMapIndices(tileIndex:Int):Array<Int>
Returns a new array full of every map index of the requested tile type.
Note: Unlike getTileInstances
this will return []
if no tiles are found
Parameters:
index | The requested tile type. |
---|
Returns:
An Array with a list of all map indices of that tile type.
5.9.0
.getAllTilePos(tileIndex:Int, midpoint:Bool = false):Array<FlxPoint>
Returns a new array full of every coordinate of the requested tile type.
Parameters:
tileIndex | The requested tile type |
---|---|
midpoint | Whether to use the tiles' midpoints, or upper left corner |
Returns:
An Array with a list of all the coordinates of that tile type
5.9.0
.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.
inlinegetColumn(mapIndex:Int):Int
Calculates the column from a map location
Parameters:
mapIndex | The location in the map where |
---|
5.9.0
.getColumnAt(worldX:Float, bind:Bool = false):Int
Finds the column number that overlaps the given X in world space
Parameters:
worldX | An X coordinate in the world |
---|---|
bind | If true, it will prevent out of range values |
Returns:
A column index, where 0 is the left-most column
5.9.0
.getColumnPos(column:Float, midPoint:Bool = false):Float
Get the world position of the specified column
Parameters:
column | The grid X location, in tiles |
---|---|
midpoint | Whether to use the tile's midpoint, or upper left corner |
5.9.0
.getData(simple:Bool = false):Array<Int>
Fetches the tilemap data array.
Parameters:
simple | If true, returns the data as copy, as a series of 1s and 0s (useful for auto-tiling stuff). Default value is false, meaning it will return the actual data array (NOT a copy). |
---|
Returns:
An array the size of the tilemap full of integers indicating tile placement.
inlinegetMapIndex(column:Int, row:Int):Int
inlinegetMapIndex(worldPos:FlxPoint):Int
Calculates a mapIndex
via row * widthInTiles + column
,
if the column or row is not valid, the result is -1
Parameters:
column | The grid X location, in tiles |
---|---|
row | The grid Y location, in tiles |
5.9.0
.inlinegetMapIndexAt(worldX:Float, worldY:Float):Int
Calculates a mapIndex
of the given location, if the coordinate
does not overlap the tilemap, the result is -1
Note: A tile's mapIndex
can be calculated via row * widthInTiles + column
Parameters:
worldX | An X coordinate in the world |
---|---|
worldY | A Y coordinate in the world |
5.9.0
.inlinegetRow(mapIndex:Int):Int
Calculates the column from a map location
Parameters:
mapIndex | The location in the map where |
---|
5.9.0
.getRowAt(worldY:Float, bind:Bool = false):Int
Finds the row number that overlaps the given Y in world space
Parameters:
worldY | A Y coordinate in the world |
---|---|
bind | If true, it will prevent out of range values |
Returns:
A row index, where 0 is the top-most row
5.9.0
.getRowPos(row:Int, midPoint:Bool = false):Float
Get the world position of the specified row
Parameters:
row | The grid Y location, in tiles |
---|---|
midpoint | Whether to use the tile's midpoint, or upper left corner |
5.9.0
.getTile(column:Int, row:Int):Int
Check the value of a particular tile.
Parameters:
column | The grid X location, in tiles |
---|---|
row | The grid Y location, in tiles |
Returns:
The tile index of the tile at this location
getTileByIndex(mapIndex:Int):Int
Get the tileIndex
at the given map location
Note: A tile's mapIndex
can be calculated via row * widthInTiles + column
Parameters:
mapIndex | The desired location in the map |
---|
Returns:
An integer containing the value of the tile at this spot in the array.
getTileCollisions(mapIndex:Int):FlxDirectionFlags
Gets the collision flags of the tile at the given location
Note: A tile's mapIndex
can be calculated via row * widthInTiles + column
Soft Deprecation
You should use getTileData(mapIndex).allowCollisions
, instead
Parameters:
mapIndex | The desired location in the map |
---|
Returns:
The internal collision flag for the requested tile.
getTileCoordsByIndex(mapIndex:Int, midpoint:Bool = true):FlxPoint
inlinegetTileData(column:Int, row:Int):Null<Tile>
inlinegetTileData(worldPos:FlxPoint):Null<Tile>
inlinegetTileData(mapIndex:Int):Null<Tile>
Finds the tile instance at a particular column and row,
if the column or row is invalid, the result is null
Parameters:
column | The grid X location, in tiles |
---|---|
row | The grid Y location, in tiles |
5.9.0
.inlinegetTileDataAt(worldX:Float, worldY:Float):Null<Tile>
Finds the tile instance with the given world location, if the
coordinate does not overlap the tilemap, the result is null
Note: The reulting tile's x
, y
, width
and height
will not be accurate.
You can call tile.orient
or similar methods
Parameters:
worldX | An X coordinate in the world |
---|---|
worldY | A Y coordinate in the world |
5.9.0
.inlinegetTileIndex(column:Int, row:Int):Int
inlinegetTileIndex(worldPos:FlxPoint):Int
inlinegetTileIndex(mapIndex:Int):Int
Check the value of a particular tile, if the
column or row is invalid, the result is -1
Parameters:
column | The grid X location, in tiles |
---|---|
row | The grid Y location, in tiles |
Returns:
The tile index of the tile at this location
5.9.0
.inlinegetTileIndexAt(worldX:Float, worldY:Float):Int
Get the tileIndex
at the given location, if the coordinate
does not overlap the tilemap, the result is -1
Parameters:
worldX | An X coordinate in the world |
---|---|
worldY | A Y coordinate in the world |
Returns:
The tileIndex of the tile at this location
5.9.0
.getTileIndexByCoords(worldPos:FlxPoint):Int
Note: This method name is misleading! It does not return a tileIndex
, it returns a mapIndex
Parameters:
worldPos | A location in the world |
---|
Returns:
The mapIndex
placed at the given world location
inlinegetTileInstances(tileIndex:Int):Array<Int>
Returns a new array full of every map index of the requested tile type
Note: Unlike getAllMapIndices
this will return null
if no tiles are found
Parameters:
index | The requested tile type. |
---|
Returns:
An Array with a list of all map indices of that tile type.
inlinegetTilePos(mapIndex:Int, midpoint:Bool = false):Null<FlxPoint>
inlinegetTilePos(worldPos:FlxPoint, midpoint:Bool = false):FlxPoint
inlinegetTilePos(column:Int, row:Int, midpoint:Bool = false):FlxPoint
Get the world position of the specified tile, if the mapIndex
is invalid,
the result is null
Note: A tile's mapIndex
can be calculated via row * widthInTiles + column
Parameters:
mapIndex | The desired location in the map |
---|---|
midpoint | Whether to use the tile's midpoint, or upper left corner |
Returns:
The world position of the matching tile
5.9.0
.inlinegetTilePosAt(worldX:Float, worldY:Float, midpoint:Bool = false):FlxPoint
Get the world position of the tile overlapping the specified position
Note: The location does not need to overlap the tilemap, to ensure a
valid tile, use if (tileExistsAt(worldX, worldY))
, first
Parameters:
worldX | An X coordinate in the world |
---|---|
worldY | A Y coordinate in the world |
midpoint | Whether to use the tile's midpoint, or upper left corner |
Returns:
The world position of the overlapping tile
5.9.0
.isOverlappingTile(object:FlxObject, ?filter:(tile:Tile) ‑> Bool, ?position:FlxPoint):Bool
Searches all tiles near the object for any that satisfy the given filter. Stops searching when the first overlapping tile that satisfies the condition is found
Parameters:
object | The object |
---|---|
filter | Function that takes a tile and returns whether is satisfies the
disired condition, if |
position | Optional, specify a custom position for the tilemap |
Returns:
Whether any overlapping tile satisfied the condition, if there was one
5.9.0
.loadMapFrom2DArray(mapData:Array<Array<Int>>, tileGraphic:FlxTilemapGraphicAsset, tileWidth:Int = 0, tileHeight:Int = 0, ?autoTile:FlxTilemapAutoTiling, startingIndex:Int = 0, drawIndex:Int = 1, collideIndex:Int = 1):FlxBaseTilemap<Tile>
Load the tilemap with string data and a tile graphic.
Parameters:
mapData | A 2D array containing the (non-negative) tile indices. The length of the inner arrays should be consistent. |
---|---|
tileGraphic | All the tiles you want to use, arranged in a strip corresponding to the numbers in MapData. |
tileWidth | The width of your tiles (e.g. 8) - defaults to height of the tile graphic if unspecified. |
tileHeight | The height of your tiles (e.g. 8) - defaults to width if unspecified. |
autoTile | Whether to load the map using an automatic tile placement algorithm (requires 16 tiles!). Setting this to either AUTO or ALT will override any values you put for StartingIndex, DrawIndex, or CollideIndex. |
startingIndex | Used to sort of insert empty tiles in front of the provided graphic. Default is 0, usually safest ot leave it at that. Ignored if AutoTile is set. |
drawIndex | Initializes all tile objects equal to and after this index as visible. Default value is 1. Ignored if AutoTile is set. |
collideIndex | Initializes all tile objects equal to and after this index as allowCollisions = ANY. Default value is 1. Ignored if AutoTile is set. Can override and customize per-tile-type collision behavior using setTileProperties(). |
Returns:
A reference to this instance of FlxTilemap, for chaining as usual :)
loadMapFromArray(mapData:Array<Int>, widthInTiles:Int, heightInTiles:Int, tileGraphic:FlxTilemapGraphicAsset, tileWidth:Int = 0, tileHeight:Int = 0, ?autoTile:FlxTilemapAutoTiling, startingIndex:Int = 0, drawIndex:Int = 1, collideIndex:Int = 1):FlxBaseTilemap<Tile>
Load the tilemap with string data and a tile graphic.
Parameters:
mapData | An array containing the (non-negative) tile indices. |
---|---|
widthInTiles | The width of the tilemap in tiles |
heightInTiles | The height of the tilemap in tiles |
tileGraphic | All the tiles you want to use, arranged in a strip corresponding to the numbers in MapData. |
tileWidth | The width of your tiles (e.g. 8) - defaults to height of the tile graphic if unspecified. |
tileHeight | The height of your tiles (e.g. 8) - defaults to width if unspecified. |
autoTile | Whether to load the map using an automatic tile placement algorithm (requires 16 tiles!). Setting this to either AUTO or ALT will override any values you put for StartingIndex, DrawIndex, or CollideIndex. |
startingIndex | Used to sort of insert empty tiles in front of the provided graphic. Default is 0, usually safest ot leave it at that. Ignored if AutoTile is set. |
drawIndex | Initializes all tile objects equal to and after this index as visible. Default value is 1. Ignored if AutoTile is set. |
collideIndex | Initializes all tile objects equal to and after this index as allowCollisions = ANY. Default value is 1. Ignored if AutoTile is set. Can override and customize per-tile-type collision behavior using setTileProperties(). |
Returns:
A reference to this instance of FlxTilemap, for chaining as usual :)
loadMapFromCSV(mapData:String, tileGraphic:FlxTilemapGraphicAsset, tileWidth:Int = 0, tileHeight:Int = 0, ?autoTile:FlxTilemapAutoTiling, startingIndex:Int = 0, drawIndex:Int = 1, collideIndex:Int = 1):FlxBaseTilemap<Tile>
Load the tilemap with string data and a tile graphic.
Parameters:
mapData | A csv-formatted string indicating what order the tiles should go in (or the path to that file) |
---|---|
tileGraphic | All the tiles you want to use, arranged in a strip corresponding to the numbers in MapData. |
tileWidth | The width of your tiles (e.g. 8) - defaults to height of the tile graphic if unspecified. |
tileHeight | The height of your tiles (e.g. 8) - defaults to width if unspecified. |
autoTile | Whether to load the map using an automatic tile placement algorithm (requires 16 tiles!). Setting this to either AUTO or ALT will override any values you put for StartingIndex, DrawIndex, or CollideIndex. |
startingIndex | Used to sort of insert empty tiles in front of the provided graphic. Default is 0, usually safest ot leave it at that. Ignored if AutoTile is set. |
drawIndex | Initializes all tile objects equal to and after this index as visible. Default value is 1. Ignored if AutoTile is set. |
collideIndex | Initializes all tile objects equal to and after this index as allowCollisions = ANY. Default value is 1. Ignored if AutoTile is set. Can override and customize per-tile-type collision behavior using setTileProperties(). |
Returns:
A reference to this instance of FlxTilemap, for chaining as usual :)
loadMapFromGraphic(mapGraphic:FlxGraphicSource, invert:Bool = false, scale:Int = 1, ?colorMap:Array<FlxColor>, tileGraphic:FlxTilemapGraphicAsset, tileWidth:Int = 0, tileHeight:Int = 0, ?autoTile:FlxTilemapAutoTiling, startingIndex:Int = 0, drawIndex:Int = 1, collideIndex:Int = 1):FlxBaseTilemap<Tile>
Load the tilemap with image data and a tile graphic. Black pixels are flagged as 'solid' by default, non-black pixels are set as non-colliding. Black pixels must be PURE BLACK.
Parameters:
mapGraphic | The image you want to use as a source of map data, where each pixel is a tile (or more than one tile if you change Scale's default value). Preferably black and white. |
---|---|
invert | Load white pixels as solid instead. |
scale | Default is 1. Scale of 2 means each pixel forms a 2x2 block of tiles, and so on. |
colorMap | An array of color values (alpha values are ignored) in the order they're intended to be assigned as indices |
tileGraphic | All the tiles you want to use, arranged in a strip corresponding to the numbers in MapData. |
tileWidth | The width of your tiles (e.g. 8) - defaults to height of the tile graphic if unspecified. |
tileHeight | The height of your tiles (e.g. 8) - defaults to width if unspecified. |
autoTile | Whether to load the map using an automatic tile placement algorithm (requires 16 tiles!). Setting this to either AUTO or ALT will override any values you put for StartingIndex, DrawIndex, or CollideIndex. |
startingIndex | Used to sort of insert empty tiles in front of the provided graphic. Default is 0, usually safest ot leave it at that. Ignored if AutoTile is set. |
drawIndex | Initializes all tile objects equal to and after this index as visible. Default value is 1. Ignored if AutoTile is set. |
collideIndex | Initializes all tile objects equal to and after this index as allowCollisions = ANY. Default value is 1. Ignored if AutoTile is set. Can override and customize per-tile-type collision behavior using setTileProperties(). |
Returns:
A reference to this instance of FlxTilemap, for chaining as usual :)
4.1.0
.objectOverlapsTiles<TObj>(object:TObj, ?callback:(Tile, TObj) ‑> Bool, ?position:FlxPoint, isCollision:Bool = true):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.
Note: To flip the callback params you can simply swap them in a arrow func, like so:
final result = objectOverlapsTiles(obj, (tile, obj)->myCallback(obj, tile));
Parameters:
object | The FlxObject you are checking for overlaps against |
---|---|
callback | An optional function that takes the overlapping tile and object
where |
position | Optional, specify a custom position for the tilemap (see |
isCollision | If true, tiles where |
Returns:
Whether there were overlaps that resulted in a positive callback, if one was specified
5.9.0
.overlaps(objectOrGroup:FlxBasic, inScreenSpace:Bool = false, ?camera:FlxCamera):Bool
Checks to see if some FlxObject overlaps this FlxObject object in world space. If the group has a LOT of things in it, it might be faster to use FlxG.overlaps(). Warning: Currently tilemaps do NOT support screen space overlap checks!
Parameters:
object | The object being tested. |
---|---|
inScreenSpace | Whether to take scroll factors into account when checking for overlap. |
camera | Specify which game camera you want. If null, getScreenPosition() will just grab the first global camera. |
Returns:
Whether or not the two objects overlap.
overlapsAt(x:Float, y:Float, objectOrGroup:FlxBasic, inScreenSpace:Bool = false, ?camera:FlxCamera):Bool
Checks to see if this FlxObject were located at the given position, would it overlap the FlxObject or FlxGroup? This is distinct from overlapsPoint(), which just checks that point, rather than taking the object's size into account. WARNING: Currently tilemaps do NOT support screen space overlap checks!
Parameters:
x | The X position you want to check. Pretends this object (the caller, not the parameter) is located here. |
---|---|
y | The Y position you want to check. Pretends this object (the caller, not the parameter) is located here. |
objectOrGroup | The object or group being tested. |
inScreenSpace | Whether to take scroll factors into account when checking for overlap. Default is false, or "only compare in world space." |
camera | Specify which game camera you want. If null getScreenPosition() will just grab the first global camera. |
Returns:
Whether or not the two objects overlap.
overlapsPoint(worldPoint:FlxPoint, inScreenSpace:Bool = false, ?camera:FlxCamera):Bool
Checks to see if a point in 2D world space overlaps this FlxObject object.
Parameters:
worldPoint | The point in world space you want to check. |
---|---|
inScreenSpace | Whether to take scroll factors into account when checking for overlap. |
camera | The desired "screen" space. If |
Returns:
Whether or not the point overlaps this object.
overlapsWithCallback(object:FlxObject, ?callback:(FlxObject, FlxObject) ‑> Bool, flipCallbackParams:Bool = false, ?position:FlxPoint):Bool
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. Only returned if the line enters the rect. |
resolution | Defaults to 1, meaning check every tile or so. Higher means more checks! |
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
.inlinerowExists(row:Int):Bool
Whether a row exists at the given map location
Parameters:
row | The grid Y location, in tiles |
---|
5.9.0
.inlinerowExistsAt(worldY:Float):Bool
Whether a row exists at the given map location
Parameters:
worldY | A Y coordinate in the world |
---|
5.9.0
.setCustomTileMappings(mappings:Array<Int>, ?randomIndices:Array<Int>, ?randomChoices:Array<Array<Int>>, ?randomLambda:() ‑> Float):Void
Set custom tile mapping and/or randomization rules prior to loading. This MUST be called BEFORE loadMap(). WARNING: Using this will cause your maps to take longer to load. Be careful using this in very large tilemaps.
Parameters:
mappings | Array of ints for remapping tiles. Ex: [7,4,12] means "0-->7, 1-->4, 2-->12" |
---|---|
randomIndices | Array of ints indicating which tile indices should be randomized. Ex: [7,4,12] means "replace tile index of 7, 4, or 12 with a randomized value" |
randomChoices | A list of int-arrays that serve as the corresponding choices to randomly choose from. Ex: indices = [7,4], choices = [[1,2],[3,4,5]], 7 will be replaced by either 1 or 2, 4 will be replaced by 3, 4, or 5. |
randomLambda | A custom randomizer function, should return value between 0.0 and 1.0. Initialize your random seed before passing this in! If not defined, will default to unseeded Math.random() calls. |
setTile(column:Int, row:Int, tileIndex:Int, redraw:Bool = true):Bool
Change the data and graphic of a tile in the tilemap.
Parameters:
column | The grid X location, in tiles |
---|---|
row | The grid Y location, in tiles |
tileIndex | The new integer data you wish to inject. |
redraw | Whether the graphical representation of this tile should change. |
Returns:
Whether or not the tile was actually changed.
setTileByIndex(mapIndex:Int, tileIndex:Int, redraw:Bool = true):Bool
Change the data and graphic of a tile in the tilemap.
Parameters:
mapIndex | The slot in the data array (Y * widthInTiles + X) where this tile is stored. |
---|---|
tileIndex | The new tileIndex to place at the mapIndex |
redraw | Whether the graphical representation of this tile should change. |
Returns:
Whether or not the tile was actually changed.
inlinesetTileIndex(mapIndex:Int, tileIndex:Int, redraw:Bool = true):Bool
inlinesetTileIndex(worldPos:FlxPoint, tileIndex:Int, redraw:Bool = true):Bool
inlinesetTileIndex(column:Int, row:Int, tileIndex:Int, redraw:Bool = true):Bool
Change the data and graphic of a tile in the tilemap.
Parameters:
mapIndex | The slot in the data array (Y * widthInTiles + X) where this tile is stored. |
---|---|
tileIndex | The new tileIndex to place at the mapIndex |
redraw | Whether the graphical representation of this tile should change. |
Returns:
Whether or not the tile was actually changed.
5.9.0
.inlinesetTileIndexAt(worldX:Float, worldY:Float, tileIndex:Int, redraw:Bool = true):Bool
Change the data and graphic of a tile in the tilemap.
Parameters:
worldX | An X coordinate in the world |
---|---|
worldY | A Y coordinate in the world |
tileIndex | The new integer data you wish to inject. |
redraw | Whether the graphical representation of this tile should change. |
Returns:
Whether or not the tile was actually changed.
5.9.0
.setTileProperties(tile:Int, allowCollisions:FlxDirectionFlags = ANY, ?callback:(FlxObject, FlxObject) ‑> Void, ?callbackFilter:Class<FlxObject>, range:Int = 1):Void
Adjust collision settings and/or bind a callback function to a range of tiles.
This callback function, if present, is triggered by calls to overlap
or objectOverlapsTiles
.
Parameters:
tile | The tile or tiles you want to adjust. |
---|---|
allowCollisions | Modify the tile or tiles to only allow collisions from certain directions, use FlxObject constants NONE, ANY, LEFT, RIGHT, etc. Default is "ANY". |
callback | The function to trigger, e.g. lavaCallback(Tile:FlxObject, Object:FlxObject). |
callbackFilter | If you only want the callback to go off for certain classes or objects based on a certain class, set that class here. |
range | If you want this callback to work for a bunch of different tiles, input the range here. Default value is 1. |
inlinetileExists(column:Int, row:Int):Bool
inlinetileExists(worldPos:FlxPoint):Bool
inlinetileExists(mapIndex:Int):Bool
Whether a tile exists at the given map location
Parameters:
column | The grid X location, in tiles |
---|---|
row | The grid Y location, in tiles |
5.9.0
.inlinetileExistsAt(worldX:Float, worldY:Float):Bool
Whether a tile exists at the given map location
Parameters:
worldX | An X coordinate in the world |
---|---|
worldY | A Y coordinate in the world |
5.9.0
.