SpriteKit - add border with SKView

182 Views Asked by At

I was wondering how you could add a border using the SKView method, I tried initwithsize but did not like it. My actual code for a border is:

self.physicsBody = [SKPhysicsBody bodyWithEdgeOfLoopRect:self.frame.size];

self.physicsBody.Dynamic = NO;

When I enter the code the border for the bottom works but the sides still allow objects to pass through them? Is there a way to fix that? Or should I delete my code and try initwithsize?

1

There are 1 best solutions below

0
On

Try this code instead:

self.physicsBody = [SKPhysicsBody bodyWithEdgeLoopFromRect:self.frame];

To get a little more familiar with physics bodies, you should read the docs on this issue to help you in the future.