【发布时间】:2018-06-07 05:31:35
【问题描述】:
我有使用 SceneView 创建多维数据集,我想消失点击动作的多维数据集。怎么实现呢?
这是我创建 Cube 的代码
SCNBox *Box = [SCNBox boxWithWidth:2.0 height:2.0 length:2.0
chamferRadius:Radius];
Box.firstMaterial.diffuse.contents = [UIColor whiteColor];
SCNNode *cubeNode = [SCNNode nodeWithGeometry:Box];
[ArrBoxNode addObject:cubeNode];
self.sceneView.backgroundColor = [UIColor redColor];
self.view.backgroundColor = [UIColor grayColor];
cubeNode.position = SCNVector3Make(4,0,0);
[scene.rootNode addChildNode:cubeNode];
self.sceneView.scene = scene;
[self.sceneView sizeToFit];
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint touchPoint = [touch locationInView:self.sceneView];
SCNHitTestResult *hitTestResult = [[self.sceneView
hitTest:touchPoint options:nil] firstObject];
SCNNode *hitNode = hitTestResult.node;
for (SCNNode *node in ArrBoxNode) {
[node removeFromParentNode];
}
}
但我无法从 Tap 操作中删除节点。能否请您帮助我,并提出更好的建议,谢谢... :)
【问题讨论】:
-
试试
[hitNode removeFromParentNode];告诉我 -
这可行,但是当我添加新多维数据集时它不起作用
-
首先检查你是否触摸了那个物体,也许是发生了什么你需要触摸你需要移除的物体,让我知道
-
工作的兄弟。非常感谢。我发现了一个问题。你能告诉我吗?
-
我在点击事件上做爆炸动画。当我删除节点时,动画不起作用。请检查
标签: ios objective-c xcode scenekit scnnode