0
我剛開始自我介紹一些,並試圖創建一個帶有凹形物理體的三面框。我正在使用一側的圖像,併爲另一側和底部使用相同的圖像。我已經爲每個位置分配了一個位置並添加到視圖中,但是當使用bodyWithBodies方法時,我得到以下Log錯誤:使用Swift異常的Spritekit bodywithbodies
由於未捕獲的異常'NSInvalidArgumentException',原因:' - [SKSpriteNode _shapes] :無法識別的選擇器發送到實例0x78737140'
帶有消息'線程1:SIGABRT'在AppDelegate類。
如果有人能讓我知道問題是什麼,那麼我會非常感激。
這裏是我的代碼:
let side1 = SKSpriteNode(imageNamed: "430x30.png")
side1.anchorPoint = CGPoint(x: 0,y: 0)
side1.position = CGPoint(x: self.size.width/2 - 100 ,y: self.size.height/2 - 100)
side1.physicsBody = SKPhysicsBody(rectangleOfSize: side1.size)
self.addChild(side1)
let side2 = SKSpriteNode(imageNamed: "430x30.png")
side2.anchorPoint = CGPoint(x: 0,y: 0)
side2.position = CGPoint(x: self.size.width/2 + 100,y: self.size.height/2 - 100)
side2.physicsBody = SKPhysicsBody(rectangleOfSize: side2.size)
self.addChild(side2)
let base = SKSpriteNode(imageNamed: "30x430.png")
base.anchorPoint = CGPoint(x: 0,y: 0)
base.position = CGPoint(x: self.size.width/2 - 100,y: self.size.height/2 - 100)
base.physicsBody = SKPhysicsBody(rectangleOfSize: base.size)
self.addChild(base)
let box = SKPhysicsBody(bodies:[base,side1,side2])
box.categoryBitMask = PhysicsCategory.Box // 3
box.contactTestBitMask = PhysicsCategory.None // 4
box.dynamic = false
感謝,
足