ios - 删除 SKSpriteNode 的所有副本

标签 ios swift sprite-kit

在循环中我有这一行,我需要删除所有副本。我如何才能在 SpriteKit 的 Swift 中做到这一点?

obstacles = obstaclesImage.copy() as! SKSpriteNode

最佳答案

命名你的节点:

obstacleCopy.name = "obstacleCopy"

然后枚举他们的父级:

self.enumerateChildNodesWithName("obstacleCopy") {
    node, stop in 
    node.removeFromParent()
}

关于ios - 删除 SKSpriteNode 的所有副本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37775676/

相关文章:

ios - 带有 clousers 的泛型错误,即 '(Any) -> Void' 不可转换为 '(T) -> Void

ios - 如何在 Swift 中为所有 iOS 设备水平居中标签

objective-c - 为所有 iOS 版本的子类 SKNode 对象创建一个便捷方法

ios - 在启动时暂停 SKScene

swift/SpriteKit : Attempting to reach a function/method in a class from another class not working

ios - 如何用动画重新加载 iCarousel?

objective-c - 订购特定格式数字的 NSString(例如 3 :23. 123)?

php - 无法将表情符号存储在数据库中

Swift - 我想从 View Controller 中的 SceneDelegate.swift 访问信息

ios - Swift 4 shouldChangeCharactersIn 只显示长度 = 12