我想要计算当精灵在特定的时间内到达之前的目的地时的新点数。我该怎么做呢?
例如,我不想先计算路径,而是想在特定持续时间结束后计算它。
PathModifier(bugduration, path, null, new IPathModifierListener()
{
public void onWaypointPassed(final PathModifier pPathModifier,final IShape pShape, final int pWaypointIndex) {
......
}
}发布于 2012-07-04 17:07:42
您可以使用onPathFinished() {},并在完成之前的操作后创建新路径。也许这不是一个好的选择,但它对我很有效。
我写了一些代码:
function go() {
HashMap<float, float> coords = calcNewCoords();
path = new Path(2).to(currentPosX, currentPosY).to(coords.get("toX"),coords.get("yoY"));
time = calcTime();
petSprite.registerEntityModifier(new PathModifier(time,
path, null, new IPathModifierListener() {
@Override
public void onPathWaypointFinished(PathModifier pPathModifier,
IEntity pEntity, int pWaypointIndex) {
// TODO Auto-generated method stub
rest();
}
}));
}
function rest() {
....
go();
}诸如此类的事情。这不是我真正的代码..但我尝试过使用onPathWaypointFinished(),它很有效!在我的游戏中有一个角色,它随机走到随机的位置,然后休息,然后去到另一个点…
https://stackoverflow.com/questions/11324573
复制相似问题