How to make a border for a scene in SpriteKit

I am trying to make a border for two sides in a scene, but there is some kind of error: here is the code I used

let leftEdge : SKNode = SKNode()
            leftEdge.physicsBody = SKPhysicsBody(edgeFromPoint: CGPointZero, toPoint: CGPointMake(0.0, self.size.height + 100))

            leftEdge.position = CGPointZero;

            self.addChild(leftEdge)

            let rightEdge : SKNode = SKNode()
            rightEdge.physicsBody = SKPhysicsBody(edgeFromPoint: CGPointZero, toPoint: CGPointMake(0.0, self.size.height + 100))
            rightEdge.position = CGPointMake(self.size.width, 0.0);

            self.addChild(rightEdge)

      

but the top border and bottom border will get borders, and both sides seem to have a border outside the scene because I shoot the object in relation to them, it exits the scene and comes back, so the question is how do I only do borders for two sides left and right

+3


source to share





All Articles