SpriteKit Coordinates differ between iPad and iPhone

前端 未结 1 707
無奈伤痛
無奈伤痛 2021-01-25 05:19

I have a very simple SpriteKit scene that is not behaving like I would expect. It is a universal app and the code that I am using to draw a single red square in the scene is as

相关标签:
1条回答
  • 2021-01-25 06:00

    This is caused because the size of the screen on iPhone is incorrect - have a look in the scene's sks file, you should see the size of the scene is set to (1024, 768) by default. To correct this you need to set the scene size and scale mode:

    scene.size = skView.bounds.size
    scene.scaleMode = .AspectFill
    

    You should do this is didMoveToView or when you instantiate the scene.

    0 讨论(0)
提交回复
热议问题