【问题标题】:Spritekit SKNode Position Always 0 in iOS8Spritekit SKNode位置在iOS8中始终为0
【发布时间】:2014-10-18 17:32:34
【问题描述】:

在 iOS 7 中,制作按钮是 Spritekit,我们创建一个 SKLabelNode,在 TouchesBegan 委托函数上,我们在触摸位置创建一个 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);
   }
}

【问题讨论】:

    标签: ios objective-c ios8 sprite-kit xcode6


    【解决方案1】:

    通过改变这个来解决:

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

    到这里:

    if([restartLabel containsPoint:touchLocation])
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多