I have mutiple objects to move on paths with different distance. How can I get the same speed of all objects?
CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@”position”];
pathAnimation.speed = 0.5;
Doesn’t work ;(
If the distance is bigger the speed increases.
I haven’t tested this idea, however, it seems like the speed is defined as relative value.
You can re-compute it into the pixel-relative value if you can compute the paths length. The speed of the animation will be
animation.speed = baseSpeedInPixels / thisPathLengthInPixels;where baseSpeedInPixels is the desired base speed constant.It might result values bigger than 1.0, if the animation class doesn’t understand this, you can re-map the timing values to keep the speed in [0,1] range.