This discussion is archived
5057 Views 9 Replies Latest reply: Sep 19, 2008 10:06 AM by Felixk
Currently Being ModeratedAug 23, 2008 7:02 PM (in response to kingsoul8)I am trying to have an image run on a continuous rotating (360 degree) loop like the second hand of clock. Maybe there is an better or easier way of doing this other than CGAffineTransformMakeRotation. I have looked at the GLSprite code and that is a little beyond me right now.iMac 2.16 GHz Intel Core 2 Duo, Mac OS X (10.5.4)
Currently Being ModeratedSep 19, 2008 5:48 AM (in response to kingsoul8)Have you figured this out?
I'm trying to do the same thing, and I can't get the rotation passed 180 degrees.
Currently Being ModeratedSep 19, 2008 5:53 AM (in response to kingsoul8)Have you tried negativ values? The first half goes from 0 - Pi, the second half from -Pi to 0. This should form a 360 degree turn.MacBook Pro, Mac OS X (10.5.5)
Currently Being ModeratedSep 19, 2008 6:17 AM (in response to just.do.it)Hey thanks for the reply..Just gave it a try,and it didn't help. Here is my code:
CABasicAnimation *rotateAnimation = |CABasicAnimation animationWithKeyPath:@"transform"|;
rotateAnimation.duration = 1;
rotateAnimation.repeatCount = 1;
rotateAnimation.autoreverses = NO;
rotateAnimation.toValue = |NSValue valueWithCATransform3D:CATransform3DRotate(touchedLayer.transform, DegreesToRadians(180), 1.0 ,0.0 ,0.0)|;
CABasicAnimation *rotateBackAnimation = |CABasicAnimation animationWithKeyPath:@"transform2"|;
rotateBackAnimation.duration = 1;
rotateBackAnimation.repeatCount = 1;
rotateBackAnimation.autoreverses = NO;
rotateBackAnimation.toValue = |NSValue valueWithCATransform3D:CATransform3DRotate(touchedLayer.transform, DegreesToRadians(-180), 1.0 ,0.0 ,0.0)|;
|touchedLayer addAnimation:rotateAnimation forKey:@"rotate"|;
|touchedLayer addAnimation:rotateBackAnimation forKey:@"rotateback"|;
Currently Being ModeratedSep 19, 2008 6:58 AM (in response to Felixk)A 360 degree transformation is no transformation, but you cn rotate something a full 360 degrees by applying a smaller rotation multiple times. I would compute the transformation for a 90degree rotation and apply that 4 times in the time you wanted to apply the 360 rotation once.iMac, Mac OS X (10.5.2), shiny
Currently Being ModeratedSep 19, 2008 7:33 AM (in response to Arca)I tried that... I set rotateAnimation.repeatCount = 4; and the angle to 90 degrees..
Basically it just rotates my view 90 degrees 4 times from the same position. Meaning the transformation isn't combining, but rather it rotates 90 degrees resets back to 0 and does it again 3 more times.
Any idea how to "combine" transformations?
Currently Being ModeratedSep 19, 2008 7:38 AM (in response to Felixk)I dont have any experience here so i could be blowing smoke- but i think you would have to save the matrix after every transformation- and combine it with the current matrix when doing a new transformation.OOOOOOOLLLLLLDDDDDDD powerbook 1ghz, Mac OS X (10.4.11)
Currently Being ModeratedSep 19, 2008 8:31 AM (in response to doniguan)Yea you are probably right...the CGAffineTransformMakeRotation actually returns a matrix...then i can use
CGAffineTransform CGAffineTransformRotate (
To transform the original Matrix.
I will give it a shot and report back.