Re: Animating "contents" property of CALayer via the delegate
Re: Animating "contents" property of CALayer via the delegate
- Subject: Re: Animating "contents" property of CALayer via the delegate
- From: Matt Neuburg <email@hidden>
- Date: Mon, 28 Sep 2009 07:56:17 -0700
- Thread-topic: Animating "contents" property of CALayer via the delegate
On Mon, 28 Sep 2009 14:16:36 +0300, Oleg Krupnov <email@hidden>
said:
>I'd like to use Core Animation to create an arbitrary animation, that
>is, I have a number of custom-drawn frames that I want to render in a
>sequence, with a good frame rate, using the Core Animation timing
>engine. How do I do this?
>
>I am looking on CAKeyframeAnimation, which could do the job using the
>code like this:
>
> CAKeyframeAnimation *anim;
> NSMutableArray *images;
> CGImageRef im;
> int i;
>
> images = [NSMutableArray array];
> for (i = 0; i < N; i++) {
> im = create_image (i);
> [images addObject:(id)im];
> CGImageRelease (im);
> }
>
> anim = [CAKeyframeAnimation animation];
> [anim setKeyPath:@"contents"];
> [anim setValues:images];
> [anim setCalculationMode:@"discrete"];
> [anim setRepeatCount:HUGE_VAL];
> [anim setDuration:1.0];
>
> [layer addAnimation:anim];
>
>However, I don't like to create all keyframe images at once, but
>instead draw them in process of animation, when the particular frame
>becomes the current frame, via the -[CALayer drawLayer:inContext:]
>delegate method. How do I do this? The delegate method seems to get
>called only once. Thanks!
You might find some architectural inspiration in Matt Gallagher's
"Asteroids" Core Animation example:
http://cocoawithlove.com/search/label/CoreAnimation
m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings
_______________________________________________
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