我有精灵在屏幕上移动,如果点击它们就会消失(即删除)。如何检查是否有子节点被触摸Swift 3
我已经覆盖了的touchesBegan FUNC如下:
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
print("touch")
let touch = touches.first!
let location = touch.location(in: self)
for child in self.children {
if child.position == location {
child.removeFromParent()
}
}
}
这似乎并没有产生任何影响,可有人告诉我,我错了?
我建议一个新的称号? – Shades
好的。现在改变它。 –
您是否设置了触摸互动以在视图中启用它们或在这些图片上添加触摸手势? – Lunarchaos42