0

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.

tuvok
  • 185
  • 2
  • 10
  • Tell me something, all the objects reach the end point at the same time, even though their perceived speed is different from the one you set to be at 0.5, correct? – MiguelB Jul 22 '11 at 11:08

1 Answers1

0

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.

Gobra
  • 4,263
  • 2
  • 15
  • 20