class flixel.util.FlxPath implements IFlxDestroyable

Available on all platforms

This is a simple path data container. Basically a list of points that * a FlxObject can follow. Also has code for drawing debug visuals. * FlxTilemap.findPath() returns a path object, but you can * also just make your own, using the add() functions below * or by creating your own array of points.

Class Fields

static var BACKWARD:Int

Path behavior controls: move from the end of the path to the start then stop.

static var FORWARD:Int

Path behavior controls: move from the start of the path to the end then stop.

static var HORIZONTAL_ONLY:Int

Path behavior controls: ignores any vertical component to the path data, only follows side to side.

static var LOOP_BACKWARD:Int

Path behavior controls: move from the end of the path to the start then directly back to the end, and start over.

static var LOOP_FORWARD:Int

Path behavior controls: move from the start of the path to the end then directly back to the start, and start over.

static var VERTICAL_ONLY:Int

Path behavior controls: ignores any horizontal component to the path data, only follows up and down.

static var YOYO:Int

Path behavior controls: move from the start of the path to the end then turn around and go back to the start, over and over.

static var manager:PathManager

The PathManager instance.

Instance Fields

var active:Bool

Pauses or checks the pause state of the path.

var angle:Float

The angle in degrees between this object and the next node, where 0 is directly upward, and 90 is to the right.

var autoCenter:Bool

Whether the object should auto-center the path or at its origin.

var debugColor:Int

Specify a debug display color for the path. Default is white.

var debugScrollX:Float

Specify a debug display scroll factor for the path. Default is (1,1). * NOTE: does not affect world movement! Object scroll factors take care of that.

var ignoreDrawDebug:Bool

Setting this to true will prevent the object from appearing * when FlxG.debugger.drawDebug is true.

var nodes:Array<FlxPoint>

The list of FlxPoints that make up the path data.

var object:FlxObject

Object which will follow this path

var speed:Float

The speed at which the object is moving on the path. * When an object completes a non-looping path circuit, * the pathSpeed will be zeroed out, but the path reference * will NOT be nulled out. So pathSpeed is a good way * to check if this object is currently following a path or not.

function new(?Object:FlxObject = null, ?Nodes:Array<FlxPoint> = null, ?Speed:Float = 100, ?Mode:Int = 0, ?AutoRotate:Bool = false):Void

Creates a new FlxPath (and calls start() right away if Object != null).

function add(X:Float, Y:Float):FlxPath

Add a new node to the end of the path at the specified location. * *

X

X position of the new path point in world coordinates. *

Y

Y position of the new path point in world coordinates.

function addAt(X:Float, Y:Float, Index:Int):FlxPath

Add a new node to the path at the specified location and index within the path. * *

X

X position of the new path point in world coordinates. *

Y

Y position of the new path point in world coordinates. *

Index

Where within the list of path nodes to insert this new point.

function addPoint(Node:FlxPoint, ?AsReference:Bool = false):FlxPath

Sometimes its easier or faster to just pass a point object instead of separate X and Y coordinates. * This also gives you the option of not creating a new node but actually adding that specific * FlxPoint object to the path. This allows you to do neat things, like dynamic paths. * *

Node

The point in world coordinates you want to add to the path. *

AsReference

Whether to add the point as a reference, or to create a new point with the specified values.

function addPointAt(Node:FlxPoint, Index:Int, ?AsReference:Bool = false):FlxPath

Sometimes its easier or faster to just pass a point object instead of separate X and Y coordinates. * This also gives you the option of not creating a new node but actually adding that specific * FlxPoint object to the path. This allows you to do neat things, like dynamic paths. * *

Node

The point in world coordinates you want to add to the path. *

Index

Where within the list of path nodes to insert this new point. *

AsReference

Whether to add the point as a reference, or to create a new point with the specified values.

function cancel():Void

Stops path movement and removes this path it from the path manager.

function destroy():Void

Clean up memory.

function drawDebug(?Camera:FlxCamera = null):Void

While this doesn't override FlxBasic.drawDebug(), the behavior is very similar. * Based on this path data, it draws a simple lines-and-boxes representation of the path * if the drawDebug mode was toggled in the debugger overlay. You can use debugColor * and debugScrollFactor to control the path's appearance. * *

Camera

The camera object the path will draw to.

function head():FlxPoint

Get the first node in the list. * *

returns

The first node in the path.

function remove(Node:FlxPoint):FlxPoint

Remove a node from the path. * NOTE: only works with points added by reference or with references from nodes itself! * *

Node

The point object you want to remove from the path. *

returns

The node that was excised. Returns null if the node was not found.

function removeAt(Index:Int):FlxPoint

Remove a node from the path using the specified position in the list of path nodes. * *

Index

Where within the list of path nodes you want to remove a node. *

returns

The node that was excised. Returns null if there were no nodes in the path.

function reset():FlxPath

function restart():FlxPath

function setNode(NodeIndex:Int):Void

Change the path node this object is currently at. * *

NodeIndex

The index of the new node out of path.nodes.

function start(Object:FlxObject, Nodes:Array<FlxPoint>, ?Speed:Float = 100, ?Mode:Int = 0, ?AutoRotate:Bool = false):FlxPath

function tail():FlxPoint

Get the last node in the list. * *

returns

The last node in the path.

function update():Void

Internal function for moving the object along the path. * Generally this function is called automatically by preUpdate(). * The first half of the function decides if the object can advance to the next node in the path, * while the second half handles actually picking a velocity toward the next node.