Packageorg.flixel
Classpublic class FlxPath
InheritanceFlxPath Inheritance Object

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.



Public Properties
 PropertyDefined By
  debugColor : uint
Specify a debug display color for the path.
FlxPath
  debugScrollFactor : FlxPoint
Specify a debug display scroll factor for the path.
FlxPath
  ignoreDrawDebug : Boolean
Setting this to true will prevent the object from appearing when the visual debug mode in the debugger overlay is toggled on.
FlxPath
  manager : DebugPathDisplay
[static] [read-only]
FlxPath
  nodes : Array
The list of FlxPoints that make up the path data.
FlxPath
Protected Properties
 PropertyDefined By
  _point : FlxPoint
Internal helper for keeping new variable instantiations under control.
FlxPath
Public Methods
 MethodDefined By
  
FlxPath(Nodes:Array = null)
Instantiate a new path object.
FlxPath
  
add(X:Number, Y:Number):void
Add a new node to the end of the path at the specified location.
FlxPath
  
addAt(X:Number, Y:Number, Index:uint):void
Add a new node to the path at the specified location and index within the path.
FlxPath
  
addPoint(Node:FlxPoint, AsReference:Boolean = false):void
Sometimes its easier or faster to just pass a point object instead of separate X and Y coordinates.
FlxPath
  
addPointAt(Node:FlxPoint, Index:uint, AsReference:Boolean = false):void
Sometimes its easier or faster to just pass a point object instead of separate X and Y coordinates.
FlxPath
  
destroy():void
Clean up memory.
FlxPath
  
drawDebug(Camera:FlxCamera = null):void
While this doesn't override FlxBasic.drawDebug(), the behavior is very similar.
FlxPath
  
Get the first node in the list.
FlxPath
  
Remove a node from the path.
FlxPath
  
removeAt(Index:uint):FlxPoint
Remove a node from the path using the specified position in the list of path nodes.
FlxPath
  
Get the last node in the list.
FlxPath
Property Detail
_pointproperty
protected var _point:FlxPoint

Internal helper for keeping new variable instantiations under control.

debugColorproperty 
public var debugColor:uint

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

debugScrollFactorproperty 
public var debugScrollFactor:FlxPoint

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.

ignoreDrawDebugproperty 
public var ignoreDrawDebug:Boolean

Setting this to true will prevent the object from appearing when the visual debug mode in the debugger overlay is toggled on.

The default value is false.

managerproperty 
manager:DebugPathDisplay  [read-only]


Implementation
    public static function get manager():DebugPathDisplay
nodesproperty 
public var nodes:Array

The list of FlxPoints that make up the path data.

Constructor Detail
FlxPath()Constructor
public function FlxPath(Nodes:Array = null)

Instantiate a new path object.

Parameters
Nodes:Array (default = null) — Optional, can specify all the points for the path up front if you want.
Method Detail
add()method
public function add(X:Number, Y:Number):void

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

Parameters

X:Number — X position of the new path point in world coordinates.
 
Y:Number — Y position of the new path point in world coordinates.

addAt()method 
public function addAt(X:Number, Y:Number, Index:uint):void

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

Parameters

X:Number — X position of the new path point in world coordinates.
 
Y:Number — Y position of the new path point in world coordinates.
 
Index:uint — Where within the list of path nodes to insert this new point.

addPoint()method 
public function addPoint(Node:FlxPoint, AsReference:Boolean = false):void

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.

Parameters

Node:FlxPoint — The point in world coordinates you want to add to the path.
 
AsReference:Boolean (default = false) — Whether to add the point as a reference, or to create a new point with the specified values.

addPointAt()method 
public function addPointAt(Node:FlxPoint, Index:uint, AsReference:Boolean = false):void

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.

Parameters

Node:FlxPoint — The point in world coordinates you want to add to the path.
 
Index:uint — Where within the list of path nodes to insert this new point.
 
AsReference:Boolean (default = false) — Whether to add the point as a reference, or to create a new point with the specified values.

destroy()method 
public function destroy():void

Clean up memory.

drawDebug()method 
public 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 visual debug mode was toggled in the debugger overlay. You can use debugColor and debugScrollFactor to control the path's appearance.

Parameters

Camera:FlxCamera (default = null) — The camera object the path will draw to.

head()method 
public function head():FlxPoint

Get the first node in the list.

Returns
FlxPoint — The first node in the path.
remove()method 
public 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!

Parameters

Node:FlxPoint — The point object you want to remove from the path.

Returns
FlxPoint — The node that was excised. Returns null if the node was not found.
removeAt()method 
public function removeAt(Index:uint):FlxPoint

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

Parameters

Index:uint — Where within the list of path nodes you want to remove a node.

Returns
FlxPoint — The node that was excised. Returns null if there were no nodes in the path.
tail()method 
public function tail():FlxPoint

Get the last node in the list.

Returns
FlxPoint — The last node in the path.