cocos creator 3.5.0 setDesignResolutionSize无效

大佬你好,我现在是用creator 3.4.1版本,使用setDesignResolutionSize也没有效果,大佬方便贴一下代码嘛?
我的代码如下:

  start() {
    const SCREEN_RATIO = 750 / 1330;
    // 动态自适应宽高
    const { width, height } = screen;
    if (width / height <= SCREEN_RATIO) {
      // 高度溢出
      console.log("高度溢出", width, height);
    } else {
      // 宽度溢出
      const _width = SCREEN_RATIO * height;
      // view.setDesignResolutionSize(_width, height, ResolutionPolicy.FIXED_HEIGHT);
      (screen as any).windowSize = new Size(_width, height);
      console.log("宽度溢出", width, height);
      console.log(_width, height);
    }
  }
    let windowSize = screen.windowSize;
    if (orientation == macro.ORIENTATION_LANDSCAPE) {
        view.setOrientation(macro.ORIENTATION_LANDSCAPE);
        if (windowSize.height > windowSize.width) {
            screen.windowSize = size(windowSize.height, windowSize.width);
        }
        view.setDesignResolutionSize(1334, 750, ResolutionPolicy.FIXED_WIDTH);
    } else {
        view.setOrientation(macro.ORIENTATION_PORTRAIT);
        if (windowSize.width > windowSize.height) {
            screen.windowSize = size(windowSize.height, windowSize.width);
        }
        view.setDesignResolutionSize(750, 1334, ResolutionPolicy.FIXED_HEIGHT);
    }

大佬你确定这个代码是 cocos creator 的 3.4.1版本嘛
我复制过来,报如下错误


大佬,其实我的需求是一个手机游戏想适配iPad端。
因为iPad比手机的高度要矮的多,在手机上是适配宽度的(FIXED_WIDTH),在iPad上的上下部分会被截断无法显示完整,想改成SHOW_ALL,但是使用各种代码都没实现。
大佬有什么方法来实现吗?

我那代码是3.5.1的
https://mp.weixin.qq.com/s/dNKloJMjVvXa7YaX7JfXDg
这是原来写的2.x的,但是屏幕是一样的,你可以看看
里边也有动态适配的方法

1赞

大佬我自己试了一下,view.setDesignResolutionSize 这个api是好用的,只不过我之前对于参数值的理解错误了,十分感谢!

大佬客气~