Re: CA: How to wait for an animation to finish?
Re: CA: How to wait for an animation to finish?
- Subject: Re: CA: How to wait for an animation to finish?
- From: Joachim Deelen <email@hidden>
- Date: Sun, 16 Mar 2008 17:43:14 +0100
Hi Jens,
maybe the Delegation Method:
- (void)animationDidStop:(CAAnimation *)animation finished:
(BOOL)finished;
is what you are looking for?!
regards
Joachim
Am 16.03.2008 um 17:03 schrieb Jens Alfke:
One thing I still haven't figured out how to do in Core Animation is
how to schedule an animation to start after previous animations have
finished. Anyone know how?
For example, in GeekGameBoard, moving a checkers piece is done by
(1) Changing the piece's superlayer to be the root layer, instead of
the square it was in
(2) Changing its position to the location of the destination square
(3) Changing its superlayer to the destination square
The problem is that changing the superlayer in steps 1 and 3 has to
be done with animations disabled, because it requires simultaneously
changing the position as well; without disabling animations, the
superlayer change causes the object to jump in position due to the
new coord system, after which it animates back to the right
location. So I wrap this in a CATransaction with animations disabled
(see ChangeSuperlayer* in the source code.)
But I found that if step (3) runs before the animation in step (2)
has completed, it interrupts the animation and causes the piece to
jump anyway.
The docs imply that [CATransaction flush] ought to block till the
previous transaction has completed, but I can't get it to do
anything. The only workaround I've found has been the very ugly one
of calling usleep(0.25e6) to wait for step 2 to finish.
It seems that the expected way to sequence animations is to create a
CAAnimation; that way I can be called when it completes, or even add
key-frames. The problem with this is that it requires that all the
layer property changes be done using a completely different API:
instead of setting layer's property directly, as I do now, I have to
create a CAAnimation object, set its parameters, and add it to the
layer. That means that the lower-level code I have that manipulates
the layers directly can't be used, and has to be duplicated using
this different API. There's got to be a better way!
Thanks...
—Jens
* line 66 of http://mooseyard.com/hg/hgwebdir.cgi/GeekGameBoard/file/af9b2b929b03/Source/QuartzUtils.m_______________________________________________
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
Joachim Deelen
AQUARIUS-software
http://www.aquarius-software.de
_______________________________________________
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