Given a PlaygroundBook page, how can you position a SpriteKit node to the right edge of the screen of the liveView
so it "snaps" there?
So far I've tried to position the node like so:
// Context: class _: SKScene
// myNode.frame.size == CGSize(width: self.frame.width / 4, height: self.frame.height)
myNode.position = CGPoint(x: self.frame.maxX - myNode.frame.size.width / 2, y: self.frame.midY)
If I were to position the node at CGPoint(x: self.frame.maxX, y: self.frame.midY)
, I would expect its center to be right at the right edge of the screen, cropping out half of the node: that doesn't happen, the node gets placed someplace where it isn't visible at all.
Additionally:
- the node positions right in the middle if I were to use
frame.midX
as thex
coordinate - the node positions at the bottom-left corner of the screen if I were to use
(0, 0)
as the position.
What am I missing? Thank you.