如果Xcode Scenekit中的节点超出范围,我如何检索它?

时间:2015-03-03 17:51:01

标签: objective-c scenekit nodename

这是Scenekit代码而不是sprite kit。所以我试图在触摸开始方法中使用它的名称来访问框,在这种情况下它是“盒子”,但它超出了范围,我尝试使用与spritekit相同的技术,但它不一样。

   //BOX
    SCNBox *boxGeometry = [SCNBox boxWithWidth:10
                                        height:10
                                        length:10
                                 chamferRadius:0.3];
    SCNNode *box = [SCNNode nodeWithGeometry:boxGeometry];
    box.position = SCNVector3Make(0, 10, 0);
    boxGeometry.firstMaterial.diffuse.contents = [UIImage imageNamed:@"wood.png"];
    boxGeometry.firstMaterial.specular.contents = [UIColor whiteColor];
    boxGeometry.firstMaterial.shininess = 10.0;
    box.name = @"box";
    [scene.rootNode addChildNode:box];




-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [touches anyObject];
    CGPoint location = [touch locationInView:self.view];


    if (location.x > 160) {
    }
    else{
    }



}

1 个答案:

答案 0 :(得分:2)

在场景-childNodeWithName:recursively:上调用rootNode