通常这不应该发生,因为运动事件通常不仅仅是一个坐标。也许您应该测试 是否historySize真的大于 2。此外,您可以添加精灵的起始坐标,否则精灵会“跳”向第一个接触点(但这不是您的问题)。
这实际上并没有什么不同——只是另一种可能性:
path= new Path(historySize);
for (int i = 0; i < historySize; i++) {
      float x = pSceneTouchEvent.getMotionEvent().getHistoricalX(i);
      float y = pSceneTouchEvent.getMotionEvent().getHistoricalY(i);
      path.to(x,y);
}
另外我注意到你开始你的for循环,int i=1所以如果你historySize是2,循环只迭代一次!
编辑
我找不到问题,但我找到了解决方案:
不要使用,而是在发生时随时motionEvent history保存 的坐标:toucheEventtouchEvent
ArrayList<Float> xCoordinates; // this is where you store all x coordinates of the touchEvents
ArrayList<Float> yCoordinates; // and here will be the y coordinates.
onSceneTouchEvent(TouchEvent sceneTouchEvent){
    switch(sceneTouchEvent.getAction()){
        case (TouchEvent.ACTION_DOWN):{  
            // init the list every time a new touchDown is registered
            xCoordinates = new ArrayList<Float>();   
            yCoordinates = new ArrayList<Float>();               
            break;
        }
        case (TouchEvent.ACTION_MOVE): {
            // while moving, store all touch points in the lists
            xCoordinates.add(sceneTouchEvent.getX());  
            yCoordinates.add(sceneTouchEvent.getY());
            break;
        }
        case (TouchEvent.ACTION_UP): {
            // when the event is finished, create the path and make the sprite move
            // instead of the history size use the size of your own lists
            Path path = new Path(xCoordinates.size());  
            for (int i = 0; i < xCoordinates.size(); i++) {
                path.to(xCoordinates.get(i), yCoordinates.get(i));  // add the coordinates to the path one by one
            }
            // do the rest and make the sprite move
            PathModifier pathModifier = new PathModifier(2.5f, path);
            pathModifier.setAutoUnregisterWhenFinished(true);
            sprite1.clearEntityModifiers();
            sprite1.registerEntityModifier(pathModifier);
            break;
        }
    }
我在我的手机上测试了这个(它不在调试模式下运行),它工作正常。但是为了确保不会抛出异常,您应该始终测试 xCoordinates 列表是否大于 1。尽管它很可能是。
好吧,我希望它至少有助于解决您最初的问题。我注意到某些方法的名称不同(例如 setAutoUnregisterWhenFinished(true);) 我猜您使用的是 AndEngine GLES1?我使用GLES2,所以当一个方法在我的代码中有另一个名称时,不要担心,只需在GLES1中查找等效名称(我没有重命名它们,因为代码按原样工作)