0

这是 Scenekit 代码而不是 sprite kit。因此,我尝试使用它的名称访问 touches started 方法中的框,在本例中为“框”,但它超出了范围,我尝试使用与 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{
    }



}
4

1 回答 1

2

呼叫-childNodeWithName:recursively:现场的rootNode

于 2015-03-03T18:32:17.413 回答