Android 路径修改

Android 路径修改,android,andengine,Android,Andengine,我想在精灵在特定时间内到达前一个目的地时计算新的点。我该怎么做 例如,我希望在特定的持续时间结束后计算路径,而不是首先计算路径 PathModifier(bugduration, path, null, new IPathModifierListener() { public void onWaypointPassed(final PathModifier pPathModifier,final IShape pShape, final int pWaypointIndex) {

我想在精灵在特定时间内到达前一个目的地时计算新的点。我该怎么做

例如,我希望在特定的持续时间结束后计算路径,而不是首先计算路径

PathModifier(bugduration, path, null, new IPathModifierListener() 
{
    public void onWaypointPassed(final PathModifier pPathModifier,final IShape pShape, final int pWaypointIndex) {
        ......
    }
}
您可以使用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();
}
函数go(){ HashMap coords=calcNewCoords(); 路径=新路径(2).to(currentPosX,currentPosY).to(coords.get(“toX”),coords.get(“yoY”); 时间=计算时间(); petSprite.registerEntityModifier(新路径修饰符)(时间, 路径,null,新的IPathModifierListener(){ @凌驾 已完成PathWayPoint上的公共无效(路径修改器pPathModifier, 连续性(Pentty,int pWaypointIndex){ //TODO自动生成的方法存根 rest(); } })); } 函数rest(){ .... go(); } 像这样的事。。。这不是我真正的代码。。但是我已经用onPathWaypointFinished()试过了,而且效果很好!!!!
在我的游戏中,有一个角色会随机移动到任意位置,然后休息并移动到另一个位置…

Hai racoon。。是的,我也知道那种方法。我的问题是旧jar在Listener中不支持onpathfinished()方法,可以尝试:新路径(2).to(currX,currY).to(newX,newY);只有一条路。这将是onWaypointPassed()。不?我想计算新的,一次又一次的,你能解释一下细节吗,你想做什么。你为什么要这么做?也许我不明白什么。。。但这很奇怪,我想用特定的长度、角度和持续时间移动精灵,例如精灵从x1,y1开始,移动到x2,y2,一旦到达x2,y2,我必须计算下一个点。。我的路径侦听器中只有一个方法,即onwaypointpassed()