Hello Dimitri.

CAAnimation* rotateAnimation = [CABasicAnimation animationWithKeyPath:@"transform"]; rotateAnimation.fromValue = [NSValue valueWithCATransform3D:nLayer.transform]; rotateAnimation.toValue = [NSValue valueWithCATransform3D:transform];

its gives me an error, Error request for member "fromValue" in something not a structure or union. shouldn't it be CABasicAnimation which has the fromValue and toValue properties.?


On 16.12.2008, at 15:13, Dimitri Bouniol wrote:

-(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]);

                CATransform3D transform = nLayer.transform;
transform = CATransform3DRotate(transform, M_PI_2, 0, 0, 1.0); // rotate additional 90 degrees

CAAnimation* rotateAnimation = [CABasicAnimation animationWithKeyPath:@"transform"]; rotateAnimation.fromValue = [NSValue valueWithCATransform3D:nLayer.transform]; rotateAnimation.toValue = [NSValue valueWithCATransform3D:transform];
                rotateAnimation.duration = 0.4;
                [rotateAnimation setValue:nLayer forKey:@"rotatedLayer"];
                [rotateAnimation setDelegate:self];

                [CATransaction begin];
[CATransaction setValue:(id)bCFBooleanTrue forKey:kCATransactionDisableActions]; nLayer.transform = transform; // set the layers "actual" value without the user noticing
                [CATransaction commit];

[nLayer addAnimation:rotateAnimation forKey:@"RotationAnimation"]; // set this so it replaces the previous rotation if you click before 0.4 sec
                
        }
        
}

Hope that works :3 (apologies if I forgot a semicolon or something, i wrote it directly in mail)

On Dec 16, 2008, at 5:54 AM, Gustavo Pizano wrote:

_______________________________________________

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