【发布时间】:2014-05-26 00:10:54
【问题描述】:
我想根据用户在屏幕上拖动手指来旋转枪。我想我需要极坐标中的笛卡尔点,并且我需要一个长按手势,这两者都是我所拥有的。我只是想知道我将如何进行编程?抱歉,我对精灵套件真的很陌生,我已经阅读了所有苹果的文档,但我很难找到这个。我的锚点是 0,0。
-(void)shootBullets:(UILongPressGestureRecognizer *) gestureRecognizer
{
double radius;
double angle;
SKSpriteNode *gun = [self newGun];
}
我想出了如何获得角度,但现在我的 zrotation 不起作用。就像我的 nslog 和角度是正确的但是当我点击 gun.zrotation 并且我点击什么都没有发生?请帮帮我,我快疯了。
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
SKSpriteNode *gun = [self newGun];
self.gunRotation = atanf(location.y/location.x)/0.0174532925;
gun.zRotation = self.gunRotation;
NSLog(@"%f",gun.zRotation);
}
【问题讨论】:
标签: ios iphone objective-c