0

根据这篇文章,我必须在我的项目中修改一些原生代码来改变 iOS 设备的屏幕方向。但是在 view.setFrameSize 函数中抛出了错误:

          setFrameSize(width, height) {
            this._frameSize.width = width;
            this._frameSize.height = height;
            legacyCC.game.frame.style.width = `${width}px`; //error here
            legacyCC.game.frame.style.height = `${height}px`; //errror here

            this._resizeEvent();
          }

带有消息:JS:[错误]:(参见堆栈)未捕获的类型错误:无法设置未定义的属性“宽度”-[0]setFrameSize@src/cocos-js/ammo-instantiated-00e7e613.js:36431

我暂时删除了那些用于测试更改方向代码的代码行。然后我看到这个视频https://streamable.com/gctcm5游戏画面被拉长了

我也尝试按照本文https://discuss.cocos2d-x.org/t/android-orientation/32313/12的建议设置DesignResolution,但它仍然不起作用。

那么如何正确更改设备分辨率呢?

我正在使用 Cocos Creator v3.2.0、XCode 12.5、iOS 14.5

4

0 回答 0