Re: Rotating a CALayer more than once is not working
Re: Rotating a CALayer more than once is not working
- Subject: Re: Rotating a CALayer more than once is not working
- From: Steve Bird <email@hidden>
- Date: Sat, 13 Dec 2008 14:59:16 -0500
On Dec 13, 2008, at 9:50 AM, Gustavo Pizano wrote:
Hello.
I want to rotate a CALayer by 90 degrees each time I click on it.
but the first attempt I tried i rotated the layer just once, and
then I click on it again and nothing happened.
You are not TRANSFORMING each time.
You are setting THE transformation to 90 degrees. When you click
again, you are again setting THE transformation to 90 degrees (where
it was already).
Try adding 90 degrees EACH time to your angle.
If you're facing North, it's the difference between "turn left" and
"turn West".
"Turn West" only works the first time. "Turn Left" works every time.
this is the code.
-(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.contents != nil) {
NSLog(@"%@",[nLayer name]);
[nLayer setTransform:CATransform3DMakeRotation(90 * M_PI / 180, 0,
0, 1.0)];
----------------------------------------------------------------
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
www.Culverson.com (toll free) 1-877-676-8175
_______________________________________________
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