在不同的分辨率下移动时保持同步?

时间:2012-07-15 20:06:19

标签: android animation android-animation

我的问题是让一个项目以相同的速度和时间在不同的屏幕上移动。此刻物品不移动或快速移动。我指定要进入的项目的两个点和最大速度。

Var _oneStep是我尝试同步分辨率。

//Get a fraction of screen size?
_oneStep = ScreenWidth / 100;

//Delta being last update time.
public void MoveItem(double Delta)
{
    //Keep at Max speed.
    if(Math.abs(_xVelocity)  > _maxSpeed || Math.abs(_yVelocity)  > _maxSpeed)
    {
        _accelerationSpeed = 0.0001f * (_maxSpeed / _oneStep);
    }
    //Or Speed up.
    else
    {
        _accelerationSpeed = 0.00030f * (_maxSpeed / _oneStep);
    }
    //Destination is above 10% distance or below speed up or down

    _xVelocity += _accelerationSpeed * Math.cos(Math.toRadians(_degrees));
    _yVelocity += _accelerationSpeed * Math.sin(Math.toRadians(_degrees));

    _currentPosition.x += (((_xVelocity * _accelerationSpeed) + _oneStep) * Delta);
    _currentPosition.y += (((_yVelocity * _accelerationSpeed) + _oneStep) * Delta);

    CheckAtDestination();
}

有些数字:

System.out.println("X: "+ _xVelocity + " Y: " + _yVelocity); = X: 1.0018943990787657 Y: 1.0109980390961948
System.out.println("XPos: "+ _currentPosition.x + " YPos: " + _currentPosition.x); = XPos: 36 YPos: 36
System.out.println("Degrees: " + _degrees); = Degrees: 80.22677351282063
System.out.println(Delta); = 0.3309303333093033

如果Delta变为1或更高,会发生什么?产生了奇怪的结果吗?

0 个答案:

没有答案