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
ios objective-c swift sprite-kit skscene


source to share


No one has answered this question yet

Check out similar questions:

1665
How can I get the UITextField to move upward when there is a keyboard - when starting editing?
1244
How can I sort NSMutableArray with custom objects in it?
1180
How can I check if a string contains another string in Objective-C?
928
How do I call Objective-C code from Swift?
795
How do I check the iOS version?
4
Fast physics edge recognition problem
1
bodyWithEdgeLoopFromRect does not make left and right borders
0
How to wrap the x & y axis in SpriteKit?
0
Swift: Spritekit: Scene switching (anchor point?)



All Articles
Loading...
X
Show
Funny
Dev
Pics