I tried to display several SKNodes, and I used the width and height of the screen to set their positions, to make them compatible with different screen sizes.
SKNode* obstacle = [SKSpriteNode spriteNodeWithColor:[SKColor greenColor] size:obstacleSize];
obstacle.position = CGPointMake(80, self.size.height * 0.38);
obstacle.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize:obstacle.frame.size];
But the positions of the nodes still change when I run the program with a different screen size (3.5 inches, but wrong in 4 inches). And I found that is self.size.heightnot the actual height of the screen.
Does anyone know how to solve this problem?
source
share