Dimitri Hi

using CAAnimation this is what I was doing:

-(void)mouseDown:(NSEvent *)event
{
        [event retain];
        [mouseDownEvent  release];
        mouseDownEvent = event;
        NSPoint p2 = [event locationInWindow];
        NSPoint p3 = [self convertPoint:p2 fromView:nil];
        CGPoint p = NSPointToCGPoint(p3);
        CALayer * nLayer = [_gameboardLayer hitTest:p];

        if (nLayer.name != nil) {
                NSLog(@"%@",[nLayer name]);
                CAAnimation* rotateAnimation = [self animateForRotating];       
                [rotateAnimation setValue:nLayer forKey:@"rotatedLayer"];
                [rotateAnimation setDelegate:self];             
                [nLayer addAnimation:rotateAnimation forKey:@"whatever"];
                
        }
        
}


-(CAAnimation *)animateForRotating
{
        float radians = 90 * M_PI / 180;
        CATransform3D transform;
        transform = CATransform3DMakeRotation(radians, 0, 0, 1.0);
        CABasicAnimation* animation;
    animation = [CABasicAnimation animationWithKeyPath:@"transform"];
        animation.toValue = [NSValue valueWithCATransform3D:transform];
        animation.duration = 0.4;
    animation.cumulative = NO;
        return animation;
}

but hte animation once finished returned the layer to the initial position something undesirable, I then set up a animation.autoreverse = NO; but that didn't help either. I can see here, somehow using CAAnimation its better, I can have more control on how the rotation should look.

What do you think?

Thanks  tons for your help


Gus



On 16.12.2008, at 14:37, Dimitri Bouniol wrote:

The Core Animation Programing Guide — http://developer.apple.com/documentation/Cocoa/Conceptual/CoreAnimation_guide/Articles/AnimProps.html#/ /apple_ref/doc/uid/TP40005942-SW2 — indicates 0.25 seconds are used for an implicit animation. As for using CABasicAnimation so you could use the delegate calls, set the property (or key path) to the final value before adding the animation to the layer, and you should get more appropriate results as the animation ends. Additionally, you might need to wrap the property call in a CATransaction to disable actions, but I don't know if it's absolutely necessary.

_______________________________________________

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