2014-07-09 189 views
0

我有一個問題,我認爲應該有一個簡單的答案(我還沒有找到!)。在我的SKScene中,所有節點都被正確定位並沿着路徑移動(基於左下角的原點),但是當我在此視圖中收集用戶觸摸座標時(下面的代碼),這些節點基於UIKit原點返回(左上)。我確信我在這裏錯過了一些非常簡單的事情;任何幫助,將不勝感激!Spritekit和UIKit座標之間的衝突

-(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { 

     UITouch *move=[[event allTouches] anyObject]; 
     CGPoint movepoint=[move locationInView:self.view]; 
     [_guide runAction:[SKAction moveTo:[[touches anyObject] locationInNode:self] duration:0.01 ]]; 

     if (recording){ 
      if (_MovePointsArray==NULL) { 
       _MovePointsArray=[[NSMutableArray alloc]init]; 
      } 
      [_MovePointsArray addObject:[NSValue valueWithCGPoint:movepoint]]; 
     } 
     curx=[NSString stringWithFormat:@"%f", movepoint.x]; 
     myXPos.text=curx; 
     cury=[NSString stringWithFormat:@"%f", movepoint.y]; 
     myYPos.text=cury; 
} 

回答

0

替代

CGPoint movepoint = [move locationInView:self.view]; 

隨着每個

- (CGPoint)locationInView:(UIView *)view 
- (CGPoint)locationInNode:(SKNode *)node 

CGPoint movepoint = [move locationInNode:self]; 

簽名