Reputation: 21966
I create a SKSpriteNode and add it to the scene graph inside my SKScene:
// First I set a white background
self.backgroundColor = SKColor.whiteColor()
let cannon = SKSpriteNode(imageNamed: "cannon")
cannon.size = CGSizeMake(32, 160)
cannon.position = CGPointMake(size.width / 2.0, 0)
self.addChild(cannon)
This is "cannon.png", which is in my Images.xcassets (my bad, it's a very ugly cannon):
If I add it I get a totally gray scene, while if I comment the last line (so I don't add the sprite to the scene), I get a white background.
Upvotes: 0
Views: 78
Reputation: 4423
You need to initialize the size
of your scene
before adding the nodes to it. Modify your init method like this and problem will be solved.
let scene = GameScene(size: view.bounds.size)
Upvotes: 1