Skip navigation.
 
mlRe: How to use CAMediaTiming's beginTime?
FROM : Bill Dudney
DATE : Thu Feb 07 22:57:02 2008

Hi Joachim,

I know this is a bit late but I'm wondering if you ever got this to 
work properly?

I am trying something similar to what you are doing here and I can't 
get it to work either.

Any insight appreciated.

Thanks,

-bd-
http://bill.dudney.net/roller/objc

On Jan 25, 2008, at 4:01 AM, Joachim wrote:

> This is a follow-up to http://lists.apple.com/archives/Cocoa-dev/2008/Jan/msg01182.html
> .
>
> I now have an animation that makes a pop while fading in. This works 
> great. It gets called implicitly for all my sublayers via the 
> [rootLayer addSublayer:layer] call, as the layer implements an 
> actionForKey: method that returns the CAAnimationGroup (see code 
> snippet at the end).
>
> However, for all the layers that are added in one round, the 
> animations runs at the exact same time. I'd like to add a bit of 
> randomness by starting the animations slightly offset to each other. 
> So I've been experimenting with CAMediaTiming's timeOffset and 
> beginTime properties. But adding one of these messes the animation up.
>
> If I set group.beginTime = CACurrentMediaTime () + 1.0; the layer 
> first appears right away (using the default animation, fading in 
> over 0.25s, I guess), and 1 second after disappears and does the 
> expected animation.
>
> If I set group.timeOffset = 1.0; the animation is just offset so 
> that it starts 1 second into the animation and "wraps around" and 
> stops after <groups.duration> seconds. After that the layer is 
> simply displayed.
>
> - I guess the beginTime is the right way to go - I just need the 
> layer not to appear before the animation starts a bit later. Any 
> ideas?
>
> Initially setting the layer to hidden or opacity = 0, makes solves 
> that problem, but also makes the layer disapear again after the 
> animation, and I'd like to avoid forcing it to stay visible in the 
> animationDidStop:finished: delegate method (also makes the layer 
> flicker).
>
> - Should I abandon the actionForKey: scenario and make the animation 
> happen by other means?
>
> Joachim
>
> - (id<CAAction>)actionForKey:(NSString *)key
> {
>  if ([key isEqualToString:kCAOnOrderIn])
>  {
>    CABasicAnimation *alphaAnim = [CABasicAnimation 
> animationWithKeyPath:@"opacity"];
>    [snip]
>    CAKeyframeAnimation *sizeAnim = [CAKeyframeAnimation 
> animationWithKeyPath:@"transform.scale"];
>    [snip]
>    CAAnimationGroup *group = [CAAnimationGroup animation];
>    group.animations = [NSArray arrayWithObjects:alphaAnim, sizeAnim, 
> nil];
>    group.duration = 1.0;
>    group.beginTime = CACurrentMediaTime () + 0.5;
>    //group.timeOffset = 0.5;
>    return group;
>  }
>  else
>      return nil;
> }
>
> _______________________________________________
>
> Cocoa-dev mailing list (<email_removed>)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>
> This email sent to <email_removed>

Related mailsAuthorDate
mlHow to use CAMediaTiming's beginTime? Joachim Jan 25, 12:01
mlRe: How to use CAMediaTiming's beginTime? Bill Dudney Feb 7, 22:57
mlRe: How to use CAMediaTiming's beginTime? Bill Dudney Feb 9, 13:09