Typed version of FlxPathfinder in case you're using a different FlxPathfinderData or FlxTilemap type.

Available since

5.0.0

.

Constructor

new(factory:FlxPathfinderDataFactory<Tilemap, Data>)

Creates a FlxTilemapPathPolicy.

Parameters:

factory

A method to create FlxTypedPathfinderData instances. Note: You don't need to create a new instances of the same policy for different maps.

Methods

@:value({ stopOnEnd : true })inlinecomputePathData(map:Tilemap, startIndex:Int, endIndex:Int, stopOnEnd:Bool = true):Data

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:

map

The map we're moving through.

startIndex

The starting tile's map index.

endIndex

The ending tile's map index.

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.

@:value({ simplify : LINE })findPath(map:Tilemap, start:FlxPoint, end:FlxPoint, simplify:FlxPathSimplifier = LINE):Null<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:

map

The map we're moving through.

start

The start point in world coordinates.

end

The end point in world coordinates.

simplify

The simplification method to run on the raw path. Default value is LINE.

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.

inlinefindPathIndices(map:Tilemap, startIndex:Int, endIndex:Int):Null<Array<Int>>

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:

map

The map we're moving through.

startIndex

The start point in world coordinates.

endIndex

The end point in world coordinates.

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.