I have parent node that is created as
var rect = SKShapeNode(points: &points, count: points.count)
Initially it has a shape of rectangle (points contain 4 CGPoint) but it can be any polygon.
And I have another node, e.g.
var square = SKShapeNode(rectOf: CGSize(width: 19, height: 19))
That is added as a child of the first one%
rect.addChild(square)
I need to be able to move square left, right, up and down by pressing corresponding buttons. I don't understand how can I move square inside the parent node that it cannot leave parent node boundaries. Once square reaches border of parent shape it should stop. Could someone help me understand how to achieve what I need?