SKScene iPad高度反转宽度 [英] SKScene iPad height width reversed

查看:71
本文介绍了SKScene iPad高度反转宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在仅支持横向模式的iPad应用中用瓷砖填充我的SKScene.在场景中,我检测到h&像这样:

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 mainScreen].bounds.size.height;
int w = [UIScreen mainScreen].bounds.size.width;

不幸的是,发送回的尺寸与所需尺寸相反.因此,在视图控制器或视图的内容中有很多讨论此问题的主题,解决方案似乎是在viewWillAppear中而不是viewDidLoad中检测屏幕大小.但是,这似乎不是SKScenes的有效解决方案.

Unfortunately, the dimensions sent back are the reverse of what they need to be. There are lots of topics in SO discussion this problem within the content of a view controller or a view, and the solution seems to be to detect screen size in viewWillAppear, not in viewDidLoad. This does not seem to be a valid solution for SKScenes, however.

有什么建议吗?

推荐答案

尝试,不要使用 viewDidLoad 并使用

- (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];
    }
}

这篇关于SKScene iPad高度反转宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆