mert
mert

Reputation: 1098

SKShapeNode is appearing wrong dimensions

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?

Upvotes: 0

Views: 91

Answers (1)

Epic Byte
Epic Byte

Reputation: 33958

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

Upvotes: 1

Related Questions