Universal App - CGPointMake

This is my code for the background chessboard. I need three different images, which is fine.

   if deviceType == "iPad" {
            backImagePad.anchorPoint = CGPointMake(0.5, 0.5)
        backImagePad.size.height = self.size.height
        backImagePad.size.width = self.size.width
        backImagePad.position = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame))
            self.addChild(backImagePad)
      }
        if (deviceType == "iPhone5" || deviceType == "iPhone6") {
        backImagePhone5.anchorPoint = CGPointMake(0.5, 0.5)
        backImagePhone5.size.height = self.size.height
        backImagePhone5.size.width = self.size.width
        backImagePhone5.position = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame))
        self.addChild(backImagePhone5)
        }
        if (deviceType == "iPhone") {
         
            backImagePhone.anchorPoint = CGPointMake(0.5, 0.5)
            backImagePhone.size.height = self.size.height
            backImagePhone.size.width = self.size.width
            backImagePhone.position = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame))
            self.addChild(backImagePhone)
        }

However, to individually position the SKSpriteNodes (chess squares) I need to specify iPhone6 and IPhone6Plus....

I do not understand why. And it is a lot of extra work. If anyone knows a way to group the iPhone6 and 6Plus with the iPhone5 for individual positioning I would appreciate it.

  H8Square.size.height = self.size.height
        H8Square.size.width = self.size.width
        H8Square.xScale = 0.1225
        if deviceType == "iPad" {
            H8Square.position = CGPointMake(720, 976)
            H8Square.yScale = 0.0920
        }
        if deviceType == "iPhone6Plus" {
            H8Square.position = CGPointMake(387.75, 710)
            H8Square.yScale = 0.0680
        }
        if deviceType == "iPhone6" {
            H8Square.position = CGPointMake(300, 548)
            H8Square.yScale = 0.0680
        }
        if deviceType == "iPhone5" {
            H8Square.position = CGPointMake(xxx, xxx)
            H8Square.yScale = 0.0680
        }
        if deviceType == "iPhone" {
            H8Square.position = CGPointMake(xxx, xxx)
            H8Square.yScale = 0.0680
        }
        self.addChild(H8Square)

Position the squares so that the center of the board is at (0,0) and the squares go off to -X, +X, -Y, and +Y. Then set the scene's anchor point to (0.5, 0.5) so that the origin is displayed in the middle of the view. Then set the scene's size to the size that you want to deal with (independent of device). Then set the scene's scaling mode to .AspectFit.


The thing to realize is that the scene's coordinate system is not necessarily related to the size or resolution of the physical screen. Everything in the scene is scaled according to the scaling mode. The .Fill scaling mode (the default) is basically the worst choice. .ResizeFill resizes the scene instead of scaling it (so that on different devices, your scene might be 1024x768 or 640x768). .AspectFit and .AspectFill let your scene coordinates have the meaning you want them to and lets your scene have the size that you specify for it, but just draws it bigger or smaller as needed, and letterboxes it or crops it.

Universal App - CGPointMake
 
 
Q