[英]Getting 'Attemped to add a SKNode which already has a parent' only on physical device, no error in code, works fine on simulator
Running my app on a simulator works fine, however, running it on a physical device gives this error.在模拟器上运行我的应用程序可以正常工作,但是,在物理设备上运行它会出现此错误。 I understand what this error means but my code seems fine, in fact, if I get rid of the trouble code (in this case the camera) another part of the code receives the same error.我理解这个错误的含义,但我的代码看起来很好,事实上,如果我摆脱了故障代码(在这种情况下是相机),代码的另一部分会收到相同的错误。
I am targeting iOS 10.3 and running on a iOS 10.3 device, it works fine on iOS 11.0 simulator我的目标是 iOS 10.3 并在 iOS 10.3 设备上运行,它在 iOS 11.0 模拟器上运行良好
code:代码:
class GameScene: SKScene {
var lastUpdateTime: TimeInterval = 0
let pigeonCam: SKCameraNode = SKCameraNode()
let pigeon: Pigeon = Pigeon()
var dt = 0.0
let ground: SKSpriteNode = SKSpriteNode(imageNamed: "Road")//crashes if camera and pigeon do not exist
override func sceneDidLoad() {
addChild(pigeonCam)//crashes
camera = pigeonCam
addChild(pigeon.pigeon)//crashes if camera code does not exist
createGround()
scene?.scaleMode = .resizeFill
}
I have tried restarting the device unit/reinstalling the app but it appears to not help, aside from a few lines of code in 'pigeon' this is the entirety of my code in the app.我已经尝试重新启动设备单元/重新安装应用程序,但它似乎没有帮助,除了“鸽子”中的几行代码之外,这是我在应用程序中的全部代码。 I'm sure it's got to do with deployment settings or something of the like but I'm stumped我确定这与部署设置或类似的东西有关,但我很难过
I have done some research, and it is quite possible the reason this is happening is because I don't have a provisioning profile我做了一些研究,很可能发生这种情况的原因是因为我没有配置文件
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.