通过平移移动组

Move a group by panning

我想通过平移移动一组Actor。

 @Override
public boolean pan(float x, float y, float deltaX, float deltaY) {
    Gdx.app.debug(TAG," Delta " + deltaX * screen.ppu + " old x "+ screen.getLevelGroup().getX());

    float newX = screen.getLevelGroup().getX() + deltaX * screen.ppu;
    Gdx.app.debug(TAG,"new X " + newX);
    screen.getLevelGroup().setX(newX);


    return true;
}

有时这不起作用。好像group的X 属性在getting和setting之间改变了。请注意,它并非一直都在发生。 错误日志文件如下:

StageSelectorGestureDetector: Delta 7.5117373 old x -639.64 StageSelectorGestureDetector: new X -632.1283

StageSelectorGestureDetector: Delta 7.5117373 old x -639.566

StageSelectorGestureDetector: new X -632.05426

StageSelectorGestureDetector: Delta 9.765259 old x -639.5344

StageSelectorGestureDetector: new X -629.76917

StageSelectorGestureDetector: Delta 5.258216 old x -639.5344

请注意,即使我设置了 X,在下一次调用 pan 时读取它也会报告旧值。

有人可以帮我吗?

问题是平移时 Action 仍然处于活动状态,因此两种方法竞争设置组的协调,因此出现奇怪的行为。