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:
Mike Thomas
2005-12-08 21:59:12 +00:00
parent db5de88da2
commit 12c9f86735
+29 -21
View File
@@ -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);