Ok that worked if I were animating just one layer on its own. However, I am animating three separate layers in sequence to one another. I know we can group multiple animations for one layer (CAGroupAnimation). Other than using a timer, is there an alternative to coordinating the animation of different layers?
Some Code: - (void) moveDots { // Animate Dot Opacity CALayer* dot = (CALayer *)[mDotLayers objectAtIndex:mDotPosition]; dot.opacity = mDotDirection ? 0.0f : 1.0f; [self setNeedsDisplay]; // NO --> Forward, YES <-- Backward if ( !mDotDirection ) mDotPosition++; if ( mDotDirection ) mDotPosition--; if ( mDotPosition < 0 ) { mDotPosition = 0; mDotDirection = NO; } if ( mDotPosition > (_noOfDots-1) ) { mDotPosition = (_noOfDots-1); mDotDirection = YES; } } - (void) _startAnimationTimer { // Just in case [self _stopAnimationTimer]; // Dot Layer Timer mDotTimer = [NSTimer timerWithTimeInterval:(NSTimeInterval)1.0f target:self selector:@selector(moveDots) userInfo:nil repeats:YES]; [mDotTimer setFireDate:[NSDate date]]; [[NSRunLoop currentRunLoop] addTimer:mDotTimer forMode:NSRunLoopCommonModes]; [[NSRunLoop currentRunLoop] addTimer:mDotTimer forMode:NSDefaultRunLoopMode]; [[NSRunLoop currentRunLoop] addTimer:mDotTimer forMode:NSEventTrackingRunLoopMode]; } Thanks, Arvin On 4/19/11 12:07 PM, "Bhatnagar, Arvin" <arvin.bhatna...@verizon.com<mailto:arvin.bhatna...@verizon.com>> wrote: Thanks David, I am going to try that suggestion right now. On 4/19/11 11:59 AM, "David Duncan" <david.dun...@apple.com<mailto:david.dun...@apple.com>> wrote: On Apr 18, 2011, at 7:49 PM, Bhatnagar, Arvin wrote: This is probably a simple question for someone other than I. I have a very simple CALayer which is a simple plain layer with a white background. I then create a CABasicAnimation and add it to the actions property to animate the @"opacity". From here I setup a timer to fire and toggle the opacity between 0 and 1 which animates. Your analysis of the timer was correct, but I wanted to talk to this point instead rather than using a timer to toggle the opacity, you could just add an animation to the layer that auto-reverses and repeats indefinitely, which would likely give you the same effect without having to run a timer at all. -- David Duncan _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com<mailto:Cocoa-dev@lists.apple.com>) 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/arvin.bhatnagar%40verizon.com This email sent to arvin.bhatna...@verizon.com<mailto:arvin.bhatna...@verizon.com>
_______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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/archive%40mail-archive.com This email sent to arch...@mail-archive.com