Add additional type of orientation to ArcPath - NONE - which keeps us from reorienting sprites following the path.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3780 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -45,6 +45,11 @@ public class ArcPath extends TimedPath
|
|||||||
* follow this path. */
|
* follow this path. */
|
||||||
public static final int FINE = 1;
|
public static final int FINE = 1;
|
||||||
|
|
||||||
|
/** An orientation indicating that the pathable should not be oriented
|
||||||
|
* as it moves along the path.
|
||||||
|
*/
|
||||||
|
public static final int NONE = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an arc path that will animate a pathable from the specified
|
* Creates an arc path that will animate a pathable from the specified
|
||||||
* starting position along an ellipse defined by the supplied
|
* starting position along an ellipse defined by the supplied
|
||||||
@@ -130,22 +135,31 @@ public class ArcPath extends TimedPath
|
|||||||
// determine where we should be along the path
|
// determine where we should be along the path
|
||||||
computePosition(_center, _xradius, _yradius, angle, _tpos);
|
computePosition(_center, _xradius, _yradius, angle, _tpos);
|
||||||
|
|
||||||
// compute the pathable's new orientation
|
// Skip this if we are not reorienting as we follow the path.
|
||||||
double theta = angle + ((_delta > 0) ? Math.PI/2 : -Math.PI/2);
|
if (_orient != NONE) {
|
||||||
int orient;
|
// compute the pathable's new orientation
|
||||||
switch (_orient) {
|
double theta = angle + ((_delta > 0) ? Math.PI/2 : -Math.PI/2);
|
||||||
default:
|
int orient;
|
||||||
case NORMAL:
|
switch (_orient) {
|
||||||
orient = DirectionUtil.getDirection(theta);
|
default:
|
||||||
// adjust it appropriately
|
case NORMAL:
|
||||||
orient = DirectionUtil.rotateCW(orient, 2*_orientOffset);
|
orient = DirectionUtil.getDirection(theta);
|
||||||
break;
|
// adjust it appropriately
|
||||||
|
orient = DirectionUtil.rotateCW(orient, 2*_orientOffset);
|
||||||
|
break;
|
||||||
|
|
||||||
case FINE:
|
case FINE:
|
||||||
orient = DirectionUtil.getFineDirection(theta);
|
orient = DirectionUtil.getFineDirection(theta);
|
||||||
// adjust it appropriately
|
// adjust it appropriately
|
||||||
orient = DirectionUtil.rotateCW(orient, _orientOffset);
|
orient = DirectionUtil.rotateCW(orient, _orientOffset);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// update the pathable's orientation if it changed
|
||||||
|
if (pable.getOrientation() != orient) {
|
||||||
|
pable.setOrientation(orient);
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// update the pathable's location if it moved
|
// update the pathable's location if it moved
|
||||||
@@ -154,12 +168,6 @@ public class ArcPath extends TimedPath
|
|||||||
modified = true;
|
modified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// update the pathable's orientation if it changed
|
|
||||||
if (pable.getOrientation() != orient) {
|
|
||||||
pable.setOrientation(orient);
|
|
||||||
modified = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if we completed our path, let the sprite know
|
// if we completed our path, let the sprite know
|
||||||
if (angle == _sangle + _delta) {
|
if (angle == _sangle + _delta) {
|
||||||
pable.pathCompleted(timestamp);
|
pable.pathCompleted(timestamp);
|
||||||
|
|||||||
Reference in New Issue
Block a user