> [[self window] setAnimations:[NSDictionary dictionaryWithObject:[self 
> shakeAnimation:[[self window] frame]] forKey:@"frameOrigin"]];
> [[[self window] animator] setFrameOrigin:[[self window] frame].origin];
>
> /*
>
>  shake animation
>  http://www.cimgf.com/2008/02/27/core-animation-tutorial-window-shake-effect/
>
>  */
> - (CAKeyframeAnimation *)shakeAnimation:(NSRect)frame
> {
>        CAKeyframeAnimation *shakeAnimation = [CAKeyframeAnimation animation];
>
>        CGMutablePathRef shakePath = CGPathCreateMutable();
>        CGPathMoveToPoint(shakePath, NULL, NSMinX(frame), NSMinY(frame));
>        int idx;
>        for (idx = 0; idx < numberOfShakes; ++idx)
>        {
>                CGPathAddLineToPoint(shakePath, NULL, NSMinX(frame) - 
> frame.size.width * vigourOfShake, NSMinY(frame));
>                CGPathAddLineToPoint(shakePath, NULL, NSMinX(frame) + 
> frame.size.width * vigourOfShake, NSMinY(frame));
>        }
>        CGPathCloseSubpath(shakePath);
>        shakeAnimation.path = shakePath;
>        shakeAnimation.duration = durationOfShake;
>        return shakeAnimation;
> }

> - (CAKeyframeAnimation *)shakeAnimation:(NSRect)frame
> {
>        CAKeyframeAnimation *shakeAnimation = [CAKeyframeAnimation animation];
>
>        CGMutablePathRef shakePath = CGPathCreateMutable();
>        CGPathMoveToPoint(shakePath, NULL, NSMinX(frame), NSMinY(frame));
>        int idx;
>        for (idx = 0; idx < numberOfShakes; ++idx)
>        {
>                CGPathAddLineToPoint(shakePath, NULL, NSMinX(frame) - 
> frame.size.width * vigourOfShake, NSMinY(frame));
>                CGPathAddLineToPoint(shakePath, NULL, NSMinX(frame) + 
> frame.size.width * vigourOfShake, NSMinY(frame));
>        }
>        CGPathCloseSubpath(shakePath);
>        shakeAnimation.path = shakePath;
>        shakeAnimation.duration = durationOfShake;
>        return shakeAnimation;
> }

Note that this code does not have any effect when compiled as 64-bit.
I don't remember all the details at the moment, but I believe the
issue is that the 'frameOrigin' property doesn't work under 64-bit. In
my own code I was forced to use the 'frame' property instead, which
changes the code a bit, but works for both 32- and 64-bit.
_______________________________________________

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

Reply via email to