2014-10-18 32 views
0

在iOS系統7使一個按鈕是Spritekit我們創建一個SKLabelNode和對的touchesBegan委託功能我們創建關於觸摸位置的SKNode並檢查節點的名稱,如果它等於打算使用的sklabelnode的名稱。 但是在iOS 8中我們遇到了問題,我們使用相同的概念,但SKNode的位置始終爲0! 那又怎麼了?Spritekit SKNode位置始終爲0在iOS8上

-(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); 
    } 
} 

回答

0

通過改變這個解決:

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

這樣:

if([restartLabel containsPoint:touchLocation])