को मैं एक UITapGestureRecognizer
और एक UIView
पर एक UIPanGestureRecognizer
उस पर एक SKScene
साथ की है। पैन इशारा पहचानकर्ता एक एसकेएनओडी को बाएं से दाएं स्थानांतरित करता है, और मैं टैप इशारा पहचानकर्ता चाहता हूं कि एसकेएनोड के बच्चे को पहचानने के लिए पैन करें। पैनिंग ठीक काम करता है, लेकिन मुझे नल का पता लगाने में परेशानी हो रही है - टैप जेस्चर प्रासंगिक विधि को सक्रिय करता है, लेकिन मुझे यकीन नहीं है कि निर्देशांक को दृश्य से दृश्य में कनवर्ट करने के लिए नोड में यह पता लगाने के लिए कि क्या टैप में से एक है बच्चों नोड्स।UITapGestureRecognizer: निर्देशांक परिवर्तित UIView से SKNode
UIView (इशारों से) → SKScene नोड
पैनिंग के नोड → बच्चे पैनिंग → मैं कैसे जाँच करते हैं एक एक टैप जेस्चर का स्पर्श समन्वय है कि क्या किसी भी SKNode है?
-(void)tapAction:(UITapGestureRecognizer*)sender{
if (sender.state == UIGestureRecognizerStateEnded)
{
// handling code
CGPoint touchLocation = [sender locationOfTouch:0 inView:sender.view];
NSLog(@"TAP %@", NSStringFromCGPoint(touchLocation)
);
for (SKLabelNode *node in _containerNode.children) {
if ([node containsPoint:[node convertPoint:touchLocation fromNode:self.parent]]) {
//This is where I want the tap to be detected.
}
CGPoint checkPoint = [node convertPoint:touchLocation fromNode:self.scene];
NSLog(@"CheckPoint %@", NSStringFromCGPoint(checkPoint)
);
//NSLog(@"iterating nodes");
if ([node containsPoint:checkPoint]) {
NSLog(@"touch match %@", node);
}
}
}
}