移動点に向かって常に移動するオブジェクトがあるアプリを作成しました。そのため、アニメーション機能は使用しませんでした。問題は、私がこの関数を作成したことです:
CGPoint center = self.im.center; // "i" is a CGPoint, im is an imageview.
if (!CGPointEqualToPoint(self.im.center, i))
{
a = (i.y-center.y)/(i.x-center.x);
//Y = a*X+b - this is a linear function in math
b = (center.y-(a*center.x));
if (i.y>center.y) {
self.im.center = CGPointMake(((center.y+1)-b)/a, center.y+1);
}
else
{
self.im.center = CGPointMake(((center.y-1)-b)/a, center.y-1);
}
}
問題は、関数が直線の水平線に近づくほど速くなるということです。これは、変化が主に X 軸に対して行われるためです。つまり、Y に 1 を追加すると、X への変化が大きくなり、移動が速くなることを意味します。
これを行う別の方法があれば、私は喜んでそれを試しますので、他の方法を知っているなら教えてください!