Why are the positions of my nodes different on each device?

Ok, so I tried to position the line on my iPhone 6s + and my iPad 2. The line was added to SKCamera (I don't know if this affects it or not). Here is the code for the line:

    var leftWall = SKSpriteNode()
    leftWall.size = CGSize(width: 1, height: 10000)
    leftWall.position = CGPoint(x: 0, y: 0)
    leftWall.color = UIColor.red
    leftWall.physicsBody = SKPhysicsBody(rectangleOf: CGSize(width: leftWall.size.width, height: leftWall.size.height))
    leftWall.physicsBody?.affectedByGravity = false
    leftWall.physicsBody?.isDynamic = false
    leftWall.physicsBody?.categoryBitMask = groundGroup
    leftWall.physicsBody?.collisionBitMask = ballGroup
    leftWall.physicsBody?.contactTestBitMask = 0
    theCamera.addChild(leftWall)

Okay, so that position x is 0.0 on the right? Here's what it looks like on my iPhone 6s +: iPhone 6s + As you can see, the line is in the middle?

Here's what it looks like on my iPad 2:

iPad 2

I just don’t understand why the line position is completely different. Please help me!

+4
source share
1 answer

You do not take into account the framing that occurs on the iPad, or your scaleMode is erroneous.

, ( ) (0.5,0.5), , GameScene view.frame(750,1334 ) .aspectFill. (0,0) , ,

+2

Source: https://habr.com/ru/post/1680529/


All Articles