0

I'm trying to create a boundary of physics for the iPad Pro 12.9

This is how I'm doing it:

override func didMove(to view: SKView) {

        physicsWorld.contactDelegate = self

        let sceneBody = SKPhysicsBody(edgeLoopFrom: self.frame)
        sceneBody.friction = 0
        self.physicsBody = sceneBody

....
}

But the Y is way off in Landscape (much lower and higher than the actual screen), and a little ways off in Portrait. But the X is right in both.

I don't know what I'm doing wrong.

Update

I've added a print to the above, and its showing the maxX and maxY of self.frame to be 375 and 667 respectively. In landscape mode. Neither of those numbers are what they should be, as far as I can tell, yet the X value works correctly whilst Y is way off the top and bottom of the screen.

This iPad model's screen resolution is 2732x2048 (half that in points) so I don't see a correlation between these numbers and the reported frame size.

2
  • Why wouldn't they be those numbers? That is the size of your scene when you set it up Sep 30, 2016 at 14:10
  • looks to me like you built your scene to be iPhone 6 size Sep 30, 2016 at 14:11

1 Answer 1

1

This has something to do with the way you're scaling the scene. When presenting a scene, you may be setting the scaleMode property of the scene, which is of type SKSceneScaleMode. There are four different modes:

  • fill: Each axis is scaled independently in order to fit the whole screen
  • aspectFill: The scene is scaled to fill the screen, but keeping the aspect ratio fixed. This is the one your scene is probably set to.
  • aspectFit: The scene is scaled to fit inside the screen, but keeps the aspect ratio. If the scene has a different aspect ratio from the device screen, there will be letter boxing.
  • resizeFill: The scene is resized to fit the view.
9
  • I'm not setting this, so far as I know. Working from default SpriteKit game template.
    – Confused
    Sep 30, 2016 at 15:24
  • From the default template, this is being set in GameViewController.swift in the didMoveToView() function. Sep 30, 2016 at 15:26
  • you would be using .aspectFill then Sep 30, 2016 at 15:37
  • You can edit the original size of the scene by going to GameScene.sks, selecting Scene, and in the attributes inspector, select the size pop-up menu and choose iPad Pro 12.9" Sep 30, 2016 at 15:44
  • Does this mean there isn't a truly generic "size" that's utterly adaptable? That it's always hard set somewhere?
    – Confused
    Sep 30, 2016 at 16:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.