Search code examples
iosswiftsprite-kitskscene

How can I set my view to the whole frame?


I am making a game in swift. I was wondering how I could fix the problem where the view of my scene does not match of with the Scene's frame.

To be more specific, I want to be able to make an edge physics body around the screen so that nothing can escape the outside of the screen. In GameScene I put self.physicsBody = SKPhysicsBody(edgeLoopFromRect: self.frame).

But this has the weird effect of covering a larger area than what I view at one time. If someone could help with this, I would be very appreciative. Thanks!


Solution

  • I found the answer. Since I was loading the GameScene from a file, the size was off a little bit. I changed the size of the scene in GameScene.sks and my program works beautifully!