A simple helper object for FlxTilemap that helps expand collision opportunities and control. You can use FlxTilemap.setTileProperties() to alter the collision properties and callback functions and filters for this object to do things like one-way tiles or whatever.
Constructor
new(tilemap:FlxTypedTilemap<FlxTile>, index:Int, width:Float, height:Float, visible:Bool, allowCollisions:FlxDirectionFlags)
Instantiate this new tile object. This is usually called from FlxTilemap.loadMap().
Parameters:
tilemap | A reference to the tilemap object creating the tile. |
---|---|
index | The actual core map data index for this tile type. |
width | The width of the tile. |
height | The height of the tile. |
visible | Whether the tile is visible or not. |
allowCollisions | The collision flags for the object. By default this value is ANY or NONE depending on the parameters sent to loadMap(). |
Variables
filter:Class<FlxObject>
Each tile can store its own filter class for their callback functions. That is, the callback will only be triggered if an object with a class type matching the filter touched it. Defaults to null, set through FlxTilemap.setTileProperties().
index:Int
The index of this tile type in the core map data. For example, if your map only has 16 kinds of tiles in it, this number is usually between 0 and 15.
mapIndex:Int = 0
The current map index of this tile object at this moment. You can think of tile objects as moving around the tilemap helping with collisions. This value is only reliable and useful if used from the callback function.
onCollide:FlxTypedSignal<(FlxTile, FlxObject) ‑> Void> = new FlxTypedSignal<FlxTile -> FlxObject>()
Dispatched whenever FlxG.collide resolves a collision with a tile of this type
5.9.0
.callbackFunction:(FlxObject, FlxObject) ‑> Void = null
This function is called whenever an object hits a tile of this type. This function should take the form myFunction(Tile:FlxTile,Object:FlxObject):void. Defaults to null, set through FlxTilemap.setTileProperties().
Methods
inlineorient(col:Int, row:Int):Void
Places this tile in the world according to the desired map location.
often used before calling overlapsObject
Calls orientAt
with the tilemap's current position
Parameters:
col | The tilemap column where this is being placed |
---|---|
row | The tilemap row where this is being placed |
5.9.0
.dynamicorientAt(xPos:Float, yPos:Float, col:Int, row:Int):Void
Places this tile in the world according to the desired map location.
often used before calling overlapsObject
This method is dynamic, meaning you can set custom behavior per tile, without extension.
Parameters:
xPos | May be the true or a theoretical x of the map, based on what called this |
---|---|
yPos | May be the true or a theoretical y of the map, based on what called this |
col | The tilemap column where this is being placed |
row | The tilemap row where this is being placed |
5.9.0
.inlineorientAtByIndex(xPos:Float, yPos:Float, mapIndex:Int):Void
Places this tile in the world according to the desired map location.
often used before calling overlapsObject
Calls orientAt
with the tilemap's current position
Note: A tile's mapIndex can be calculated via row * widthInTiles + column
Parameters:
mapIndex | The desired location in the map |
---|
5.9.0
.inlineorientByIndex(mapIndex:Int):Void
Places this tile in the world according to the desired map location.
often used before calling overlapsObject
Calls orientAt
with the tilemap's current position
Note: A tile's mapIndex can be calculated via row * widthInTiles + column
Parameters:
mapIndex | The desired location in the map |
---|
5.9.0
.dynamicoverlapsObject(object:FlxObject):Bool
Whether this tile overlaps the object. this should be called directly after calling
orient
to ensure this tile is in the correct world space.
This method is dynamic, meaning you can set custom behavior per tile, without extension.
5.9.0
.