SKShapeNode is appearing wrong dimensions

92 views Asked by At

I opened spritekit app sample and than added this code

override func didMoveToView(view: SKView) {
    /* Setup your scene here */

    var shapeNode = SKShapeNode(rect: view.frame)
    shapeNode.strokeColor = UIColor.redColor()
    shapeNode.lineWidth = 4;
    shapeNode.position = CGPoint(x: 0, y: 0)

    self.addChild(shapeNode)
}

which simply tries to add 4width border in the main view but instead of that output was, enter image description here

So what am I doing wrong?

1

There are 1 answers

0
Epic Byte On BEST ANSWER

This is because your scene is being scaled. To fix the issue change your scene scale mode (in the GameViewController) to scene.scaleMode = .ResizeFill

To see why this is, I recommend you read my answer here