• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Simultaneous CoreAnimations
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Simultaneous CoreAnimations


  • Subject: Re: Simultaneous CoreAnimations
  • From: Patrick Mau <email@hidden>
  • Date: Sun, 02 Nov 2008 23:35:08 +0100

Hallo Jeshua

The following is all written from memory, not looking at actual code.

To receive notifications, you have to set and impplement a delegate and
use it in your CALayer. Like this:

- (void) setupLayer
{
    	CABasicAnimation *anim = [CABasicAnimation animation];
    	CALayer *myLayer = [CALayer layer];

	[layer setDelegate:self];
	[layer setNeedsDisplay]; // also calls the delegate, if implemented

	[rootLayer addSubLayer:layer];

    	anim.keyPath = @"transform.rotation.x";
    	anim.duration = 5.0;
    	anim.repeatCount = 1.0;
    	anim.autoreverses = NO;
    	anim.fromValue = [NSNumber numberWithFloat:0.0];
    	anim.toValue = [NSNumber numberWithFloat:2.0*M_PI];

    	[layer addAnimation:anim forKey:@"rotate_x"];
	// since we registered 'self' as the delegate, we'll
	// receive the message below when the animation has finished
}

- (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag
{
	// theAnimation is the CABasicAnimation object used above
}

- (void) drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx
{
	// draw layer content, triggered by 'setNeedsDisplay' above.
}

You can implement a single delegate object for all registered animations.

I hope my short answer gives you enough clues, otherwise I implement a complete
example.


Regards,
Patrick

On 02.11.2008, at 23:13, Jeshua Lacock wrote:


On Nov 2, 2008, at 1:57 PM, Patrick Mau wrote:

On 02.11.2008, at 20:10, Jeshua Lacock wrote:
Hello again,

Hi Jeshua

Hi Patrick,

Thanks for your help - that looks perfect!

I have one question - hopefully not for myself this time. :)

Is there a callback or some way to determine when a CAKeyframeAnimation has finished playing? Or do I need to set up a timer and calculate when a animation has played (assuming the repeatCount is set to 1)?

I would like to be able to reuse my array of CAKeyframeAnimations, but I only want to reuse them if they have finished playing a given animation...

Have a look the abstract class 'CAAnimation' that invokes this delegate method:


- (void)animationDidStop:(CAAnimation *)theAnimation finished: (BOOL)flag

It also indicates if the animation did stop on its own or has been
removed. Simply implement this message in the CALayers delegate.


I implemented that message in the same class as I am invoking the CAAnimation, and it is not being called.

I am not sure what you mean by the CALayers delegate. Is the function in my class the delegate method?


Thanks again,

Jeshua Lacock
Founder/Programmer
3DTOPO Incorporated
<http://3DTOPO.com>
Phone: 877.240.1364


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


References: 
 >Re: Simple Flipbook Animation? (From: Jeshua Lacock <email@hidden>)
 >Re: Simple Flipbook Animation? (From: Matt Long <email@hidden>)
 >Re: Simple Flipbook Animation? (From: Jeshua Lacock <email@hidden>)
 >Simultaneous CoreAnimations (From: Jeshua Lacock <email@hidden>)
 >Re: Simultaneous CoreAnimations (From: Jeshua Lacock <email@hidden>)
 >Re: Simultaneous CoreAnimations (From: Jeshua Lacock <email@hidden>)
 >Re: Simultaneous CoreAnimations (From: Jeshua Lacock <email@hidden>)
 >Re: Simultaneous CoreAnimations (From: Patrick Mau <email@hidden>)
 >Re: Simultaneous CoreAnimations (From: Jeshua Lacock <email@hidden>)

  • Prev by Date: Re: Simultaneous CoreAnimations
  • Next by Date: Re: NSNetService won't resolve
  • Previous by thread: Re: Simultaneous CoreAnimations
  • Next by thread: Need help to make this method prettier
  • Index(es):
    • Date
    • Thread