Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spritekit SKNode位置在iOS8中始终为0_Ios_Objective C_Ios8_Sprite Kit_Xcode6 - Fatal编程技术网

Spritekit SKNode位置在iOS8中始终为0

Spritekit SKNode位置在iOS8中始终为0,ios,objective-c,ios8,sprite-kit,xcode6,Ios,Objective C,Ios8,Sprite Kit,Xcode6,在iOS 7中,要使按钮为Spritekit,我们将创建一个SKLabelNode,并在touchesBegind委托函数上,我们将在touch位置创建一个SKNode,并检查该节点的名称是否与预期的SKLabelNode的名称相同。 但在iOS 8中,我们遇到了一个问题,我们使用了相同的概念,但SKNode的位置始终为0! 怎么了 -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { for (UITouch

在iOS 7中,要使按钮为Spritekit,我们将创建一个SKLabelNode,并在touchesBegind委托函数上,我们将在touch位置创建一个SKNode,并检查该节点的名称是否与预期的SKLabelNode的名称相同。 但在iOS 8中,我们遇到了一个问题,我们使用了相同的概念,但SKNode的位置始终为0! 怎么了

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
   for (UITouch *touch in touches)
   {
       CGPoint touchLocation = [touch locationInNode:self];
       SKNode *n = [self nodeAtPoint:touchLocation];
       NSLog(@"Node Position: %f, %f", n.position.x, n.position.y);
   }
}

通过更改此选项可以解决此问题:

if (n != self && [n.name isEqual: @"restartLabel"])
为此:

if([restartLabel containsPoint:touchLocation])