I've just updated to XCode 13.0 (13A233), and I noticed that my project behaves differently (on the simulator). Here is a snippet of the code:
class GameScene: SKScene {
override func didMove(to view: SKView) {
let backgroundSprite = SKSpriteNode(imageNamed: "background")
backgroundSprite.position = CGPoint(x: 512, y: 384)
backgroundSprite.blendMode = .replace
backgroundSprite.zPosition = -1
addChild(backgroundSprite)
physicsBody = SKPhysicsBody(edgeLoopFrom: frame)
makeSlot(at: CGPoint(x:128, y:0), isGood: true)
makeSlot(at: CGPoint(x:384, y:0), isGood: false)
makeSlot(at: CGPoint(x:640, y:0), isGood: true)
makeSlot(at: CGPoint(x:896, y:0), isGood: false)
}
func makeSlot(at position: CGPoint, isGood: Bool){
let slotSprite: SKSpriteNode
if isGood {
slotSprite = SKSpriteNode(imageNamed: "slotBaseGood")
} else {
slotSprite = SKSpriteNode(imageNamed: "slotBaseBad")
}
slotSprite.position = position
slotSprite.physicsBody = SKPhysicsBody(rectangleOf: slotSprite.size)
slotSprite.physicsBody?.isDynamic = false
addChild(slotSprite)
}
}
The output is: https://i.stack.imgur.com/QkUhU.png
But, if I change the y coordinate of the CGPoints to be non zero. i.e.:
override func didMove(to view: SKView) {
let backgroundSprite = SKSpriteNode(imageNamed: "background")
backgroundSprite.position = CGPoint(x: 512, y: 384)
backgroundSprite.blendMode = .replace
backgroundSprite.zPosition = -1
addChild(backgroundSprite)
physicsBody = SKPhysicsBody(edgeLoopFrom: frame)
makeSlot(at: CGPoint(x:128, y:30), isGood: true)
makeSlot(at: CGPoint(x:384, y:30), isGood: false)
makeSlot(at: CGPoint(x:640, y:30), isGood: true)
makeSlot(at: CGPoint(x:896, y:30), isGood: false)
}
Then I can see the the expected result (well.. not really). Output: https://i.stack.imgur.com/DdMX1.png
It is as if there is a bug that cause an extra margin at the bottom of the screen. Note:
- The same code works previously in XCode 12 (I didnt have to add extra 30 points to y coordinate)
- If I open the same code that was written in XCode 12 before, then it works ok (i.e. i didnt have to add that extra 30 points). I should also mention that I noticed this behaviour when I tried to redo the project in XCode 13.
- Code works OK on actual device (I didnt have to add extra 30 points to y coordinate).
So... based on point 3.. I guess this is an XCode bug? Or have I missed something in the XCode 13 release notes?