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