-1

画面の上から下に垂直にアニメーションするボタンであるスポットがいくつかあります。
以下を実装しました。

spot.animate().x(x2).y(y2).scaleX(SCALE_X).scaleY(SCALE_Y).setDuration(animationTime).setListener
  (
     new AnimatorListenerAdapter() 
     {
        @Override
        public void onAnimationStart(Animator animation)
        {
            animators.add(animation);
        }
        public void onAnimationEnd(Animator animation)
        {
            animators.remove(animation);
            if (!gamePaused ) 
            {
               ....
            } 
        } 
     } 
  ); 

質問:

ボタンがアニメーションの開始時に加速し、アニメーションの終了時に減速することを発見しました。

LinearInterpolatorアニメーションが移動中に一定の速度になるようにコードを変更するにはどうすればよいでしょうか?

ありがとう!!

4

1 に答える 1

1

ViewPropertyAnimator クラスのsetInterpolator(TimeInterpolator interpolator)メソッドを使用しようとしましたか? したがって、コードは次のようになります。

spot.animate().x(x2).y(y2).scaleX(SCALE_X).scaleY(SCALE_Y).setInterpolator(new LinearInterpolator()).setDuration(animationTime).setListener(
    new AnimatorListenerAdapter() 
    {
       @Override
       public void onAnimationStart(Animator animation)
       {
          animators.add(animation);
       } 

       public void onAnimationEnd(Animator animation)
       {
          animators.remove(animation);

          if (!gamePaused ) 
          {
             ....
          } 
       } 
    } 
); 
于 2013-12-07T06:38:57.110 に答える