0

スプライトが特定の時間内に前の目的地に到達したときの新しいポイントを計算したいと考えています。これどうやってするの?

たとえば、パスを最初に計算する代わりに、その特定の期間が終了した後に計算したいと考えています。

PathModifier(bugduration, path, null, new IPathModifierListener() 
{
    public void onWaypointPassed(final PathModifier pPathModifier,final IShape pShape, final int pWaypointIndex) {
        ......
    }
}
4

1 に答える 1

0

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() を試してみましたが、うまくいきました!!!! 私のゲームには、休んで別のポイントに行くよりも、ランダムな側からランダムな位置まで歩くキャラクターがいます...

于 2012-07-04T09:07:42.343 に答える