有几个SKNode都给我这个问题,我宣布节点相当标准,例如
let face = SKSpriteNode(imageNamed:"final.png")// <- this is the line it points to
face.position = CGPoint(x: self.frame.size.width*0.5, y: self.frame.size.height*0.5)
face.xScale = 1
face.yScale = 1
addChild(face)
但是,当需要加载精灵时,我的游戏崩溃了。我还尝试了另一种方法,例如:
let face = SKTexture(imageNamed: "final.png")// <- this is the line it points to
show = SKSpriteNode(texture: face)
show.position = CGPoint(x: self.frame.size.width*0.5, y: self.frame.size.height*0.5)
show.xScale = 1
show.yScale = 1
addChild(show)
仍然,问题仍然存在。游戏在我的iDevice上崩溃,并且xCode给出错误消息。但是,它突出显示了我引用我的图片的行并说: EXC_BAD_ACCESS(code = 1,address = 0xa001800
最佳答案
如果您已将图片添加为imageAsset,请在调用png时删除其结尾:
let face = SKSpriteNode(imageNamed:"final")// <- this is the line it points to
关于ios - Xcode游戏崩溃并指向SpriteNode,说“EXC_BAD_ACCESS(code = 1,address = 0xa001800”,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30312641/