public class LineSegmentPath extends Object implements DirectionCodes, Path
CARDINAL_DIRECTIONS, CCW, CW, DIRECTION_COUNT, DOWN, EAST, EASTNORTHEAST, EASTSOUTHEAST, FINE_DIRECTION_COUNT, HORIZONTAL, LEFT, NONE, NORTH, NORTHEAST, NORTHNORTHEAST, NORTHNORTHWEST, NORTHWEST, RIGHT, SOUTH, SOUTHEAST, SOUTHSOUTHEAST, SOUTHSOUTHWEST, SOUTHWEST, UP, VERTICAL, WEST, WESTNORTHWEST, WESTSOUTHWEST| Constructor and Description |
|---|
LineSegmentPath()
Constructs an empty line segment path.
|
LineSegmentPath(int x1,
int y1,
int x2,
int y2)
Constructs a line segment path that consists of a single segment connecting the point
(x1, y1) with (x2, y2). |
LineSegmentPath(List<Point> points)
Constructs a line segment path with the specified list of points.
|
LineSegmentPath(Point p1,
Point p2,
int dir)
Construct a line segment path between the two nodes with the specified direction.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addNode(int x,
int y,
int dir)
Add a node to the path with the specified destination point and facing direction.
|
void |
fastForward(long timeDelta)
This is called if the pathable is paused for some length of time and then unpaused.
|
int |
getFinalOrientation()
Returns the orientation the sprite will face at the end of the path.
|
PathNode |
getNode(int idx)
Return the requested node index in the path, or null if no such index exists.
|
void |
init(Pathable pable,
long timestamp)
Called once to let the path prepare itself for the process of animating the supplied
pathable.
|
void |
paint(Graphics2D gfx)
Paint this path on the screen (used for debugging purposes only).
|
void |
setDuration(long millis)
Computes the velocity at which the pathable will need to travel along this path such that
it will arrive at the destination in approximately the specified number of milliseconds.
|
void |
setVelocity(float velocity)
Sets the velocity of this pathable in pixels per millisecond.
|
int |
size()
Return the number of nodes in the path.
|
boolean |
tick(Pathable pable,
long timestamp)
Called to request that this path update the position of the specified pathable based on the
supplied timestamp information.
|
String |
toString() |
void |
wasRemoved(Pathable pable)
When a path is removed from a pathable, whether that is because the path was completed or
because it was replaced by another path, this method will be called to let the path know
that it is no longer associated with this pathable.
|
public LineSegmentPath()
public LineSegmentPath(int x1,
int y1,
int x2,
int y2)
(x1, y1) with (x2, y2). The orientation for the first node is set
arbitrarily and the second node is oriented based on the vector between the two nodes (in
top-down coordinates).public LineSegmentPath(Point p1, Point p2, int dir)
public int getFinalOrientation()
public void addNode(int x,
int y,
int dir)
x - the x-position.y - the y-position.dir - the facing direction.public PathNode getNode(int idx)
idx - the node index.public int size()
public void setVelocity(float velocity)
velocity - the pathable velocity in pixels per millisecond.public void setDuration(long millis)
public void init(Pathable pable, long timestamp)
PathPath.tick(com.threerings.media.util.Pathable, long) after Path.init(com.threerings.media.util.Pathable, long) with the same
initialization timestamp.public boolean tick(Pathable pable, long timestamp)
Pathpublic void fastForward(long timeDelta)
PathfastForward in interface Pathpublic void wasRemoved(Pathable pable)
PathwasRemoved in interface Pathpublic void paint(Graphics2D gfx)
PathCopyright © 2015. All rights reserved.