SKScene iPad height width reversed

前端 未结 2 1775
慢半拍i
慢半拍i 2021-01-18 10:55

I am trying to fill my SKScene with tiles, in an iPad app that only supports landscape mode. Within the scene I detect h & w as such:

int h = [UIScreen          


        
2条回答
  •  粉色の甜心
    2021-01-18 11:22

    Try, not using viewDidLoad and use this

    - (void)viewWillLayoutSubviews
    {
        [super viewWillLayoutSubviews];
    
        SKView * skView = (SKView *)self.view;
        if (!skView.scene) {
            skView.showsFPS = YES;
            skView.showsNodeCount = YES;
    
            SKScene * scene = [MyScene sceneWithSize:skView.bounds.size];
            scene.scaleMode = SKSceneScaleModeAspectFill;
    
            // Present the scene.
            [skView presentScene:scene];
        }
    }
    

提交回复
热议问题