我在我的GameScene中正確定位兩個SKSpriteNodes有點麻煩。我的節點出現在場景中,但它們放大並佔據整個場景的大部分。我想有類似這樣的輸出:在GameScene中定位SKSpriteNodes
這裏是我當前的代碼:
let size = CGRect(x: 100, y:98, width:200, hight:271)
bottomRectangle = SKSpriteNode(imageNamed: "bottomRectangle")
bottomRectangle.zPosition = 3
bottomRectangle.size.height = self.size.height
bottomRectangle.size.width = self.size.width
bottomRectangle.position = CGPoint(x: 200, y:271)
bottomRectangle.physicsBody = SKPhysicsBody(edgeLoopFromRect: size)
self.addChild(bottomRectangle)
topRectangle = SKSpriteNode(imageNamed: "topRectangle")
topRectangle.physicsBody = SKPhysicsBody(edgeLoopFromRect: size)
topRectangle.zPosition = 4
topRectangle.size.height = self.size.height
topRectangle.size.width = self.size.width
topRectangle.position = CGPoint(x: 100, y: 98)
self.addChild(topRectangle)
此代碼不能編譯。你在'bottomRectangle'裏面加入'SKSpriteNode'然後加上'CGPoint'。 –
我編輯並更新了我的代碼。 – Seed12