问题描述
|
有没有人有更好的方法来用一根手指旋转精灵?我的问题是,在将精灵完全旋转两次之后,我无法使它停止旋转,我会周期性地将屏幕翻转180度(self.rotation = 180;),然后再将其翻转回(self.rotation = 0)。但是,当我将其翻转到180度时,子画面将无法正确旋转。
有谁比这更好的主意?
CGFloat gRotation;
- (void)update:(ccTime)delta
{
g.rotation = gRotation;
}
- (void)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInView:[touch view]];
location = [[CCDirector sharedDirector] convertToGL:location];
if (CGRectContainsPoint(g.boundingBox,location))
{
CGPoint firstLocation = [touch previousLocationInView:[touch view]];
CGPoint location = [touch locationInView:[touch view]];
CGPoint touchingPoint = [[CCDirector sharedDirector] convertToGL:location];
CGPoint firstTouchingPoint = [[CCDirector sharedDirector] convertToGL:firstLocation];
CGPoint firstVector = ccpSub(firstTouchingPoint,g.position);
CGFloat firstRotateAngle = -ccpToAngle(firstVector);
CGFloat previousTouch = CC_RADIANS_TO_DEGREES(firstRotateAngle);
CGPoint vector = ccpSub(touchingPoint,g.position);
CGFloat rotateAngle = -ccpToAngle(vector);
CGFloat currentTouch = CC_RADIANS_TO_DEGREES(rotateAngle);
gRotation += currentTouch - previousTouch;
}
}
谢谢
编辑:
我进入GameConfig.h并将#define GAME_AUTOROTATION kGameAutorotationUIViewController
更改为#define GAME_AUTOROTATION kGameAutorotationNone
然后,进入AppDelegate.m并将#if GAME_AUTOROTATION == kGameAutorotationUIViewController
更改为#if GAME_AUTOROTATION == kGameAutorotationNone
当我翻转屏幕时,可以固定精灵的旋转,但是在旋转两整圈后仍然无法阻止精灵的旋转。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)