SpriteKit: How to create a region that's the same size as the device screen?

Hello,

I’m working in SpriteKit and I need to create a ‘playable area’, an area that is same size as the device screen so that I can stop my player from moving off-screen.

I’m using the following line of code:

var playableRect: CGRect = UIScreen.main.bounds

But the resulting rectangle is about a quarter of the device screen, with a corner of that rectangle at what looks to be the center of the screen. And the device orientation doesn’t change that.

I’ve tried everything I can think of. Nothing is working.

How do I create a rectangle that’s the same size as the device screen?

Thank you

@kenkelm Do you still have issues with this?

Hi…thanks for the response!

I do still have trouble with this. Is there a way to create a ‘playable area’ that is same size as the device screen so that I can stop my player from moving off-screen?

Thanks in advance,

Mary

Did you ever get a resolution to this problem? I might be able to help if this is still something you are having a problem with.