我在向我的纺车添加动力时遇到困难。
我有这个轮子(类似于this),我用一个触摸事件围绕它的中心旋转它。
这里没有问题,但是当触摸(又名拖动)结束时;我想让车轮保持动力并缓解它的运动。
任何人谁可以给我一些指针,它不一定要在objective-c。 AS3,javascript或JAVA也足够了。iPhone车轮(财富)旋转势头
* UPDATE(用于旋转轮代码)*
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
rotation = _startAngle = atan2(384 - touchPoint.y, 512 - touchPoint.x);
};
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
CGPoint touchPoint = [[touches anyObject] locationInView:self.view];
rotation = atan2(384 - touchPoint.y, 512 - touchPoint.x);
rotation = fmod(rotation - _startAngle, M_PI * 2.0f);
[wheel setTransform:CGAffineTransformMakeRotation(_circleRotationOffset + rotation)];
};
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
_circleRotationOffset = fmod(_circleRotationOffset + rotation, M_PI * 2);
};
到底是如何处理你的旋转?发布一些代码。 – Jumhyn 2012-01-16 17:58:35
^更新了我的文章w /代码 – basvk 2012-01-17 07:44:49