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); } }}
}
解决方法 最后,我需要从建议的步骤中做更多的步骤 – 从SKVIEw→SKScene转换到包含我正在测试的节点的SKNode.CGPoint touchLocation = [sender locationOftouch:0 inVIEw:sender.vIEw]; CGPoint touchLocationInScene = [[self.scene vIEw] convertPoint:touchLocation toScene:self.scene]; CGPoint touchLocationInNode = [self.scene convertPoint:touchLocationInScene toNode:_containerNode];总结
以上是内存溢出为你收集整理的ios – SKNode上的UITapGestureRecognizer:将坐标从UIView转换为SKNode全部内容,希望文章能够帮你解决ios – SKNode上的UITapGestureRecognizer:将坐标从UIView转换为SKNode所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)