在微信小游戏上ui被压缩


在微信小游戏上进入游戏偶尔会出现ui被压缩的情况,但背景图却是能够适配的,ui图除了部分加了对齐组件外也没做任何改变大小或缩放的操作,请问下这个该从哪个方向去寻找问题呢?

这个问题,我也遇到了,2.4.x版本不会,只有3.x版本会出现,试了下空工程也会出现:
正常情况图片:


被拉伸后图片:

希望引擎组能关注下!
我这边是华为手机,鸿蒙系统,出现的问题。

1赞

没人遇到过这个问题嘛?

一样遇到了类似的情况,鸿蒙系统下2.4升级到3.3.2的项目,动态生成的数字缩放有问题:同时生成多个节点,设置相同的缩放值,但是表现出来的却是彼此大小不一,但是位置是没问题的

我用2.4.4也遇到了,不过出现概率很低, 微信小游戏

棋牌也能上架吗 好像得一系列资质才能了

这个问题很快就修复, 我自己弄了个临时解决方案已经提交给官方了。

你好,麻烦能分享一下临时解决方案吗,万分感谢 :6:

替换构建后的game.js文件,因为宽高数据反了,好几处有用到,直接修改了,iso虽然数据也是错的的,但是不需要修改,也不会有问题

const systemInfo = wx.getSystemInfoSync();

const isIOS = systemInfo.system.indexOf(‘iOS’) >= 0;

let _w = systemInfo.screenWidth;

let _h = systemInfo.screenHeight;

let _winw = systemInfo.windowWidth;

let _winh = systemInfo.windowHeight;

if (!isIOS) {

if (systemInfo.deviceOrientation == 'portrait') {

    _w = Math.min(systemInfo.screenWidth, systemInfo.screenHeight);

    _h = Math.max(systemInfo.screenWidth, systemInfo.screenHeight);

    _winw = Math.min(systemInfo.windowWidth, systemInfo.windowHeight);

    _winh = Math.max(systemInfo.windowWidth, systemInfo.windowHeight);

} else {

    _w = Math.max(systemInfo.screenWidth, systemInfo.screenHeight);

    _h = Math.min(systemInfo.screenWidth, systemInfo.screenHeight);

    _winw = Math.max(systemInfo.windowWidth, systemInfo.windowHeight);

    _winh = Math.min(systemInfo.windowWidth, systemInfo.windowHeight);

}

systemInfo.screenWidth = _w;

systemInfo.screenHeight = _h;

systemInfo.windowWidth = _winw;

systemInfo.windowHeight = _winh;

wx.getSystemInfoSync = function () {

    return systemInfo;

}

}

require(’./libs/wrapper/builtin/index’);

// Adapt for IOS, swap if opposite

if (canvas) {

canvas.width = window.devicePixelRatio * _w;

canvas.height = window.devicePixelRatio * _h;

}

if (canvas) {

canvas.width = window.devicePixelRatio * systemInfo.screenWidth;

canvas.height = window.devicePixelRatio * systemInfo.screenHeight;

}

const firstScreen = require(’./first-screen’);

window.DOMParser = require(’./libs/common/xmldom/dom-parser’).DOMParser;

require(’./libs/common/engine/globalAdapter/index’);

require(’./libs/wrapper/unify’);

require(’./libs/wrapper/fs-utils’);

// Polyfills bundle.

require(“src/polyfills.bundle.js”);

// SystemJS support.

require(“src/system.bundle.js”);

const importMap = require(“src/import-map.js”).default;

System.warmup({

importMap,

importMapUrl: 'src/import-map.js',

defaultHandler: (urlNoSchema) => {

    require('.' + urlNoSchema);

},

handlers: {

    'plugin:': (urlNoSchema) => {

        requirePlugin(urlNoSchema);

    },

},

});

/**

  • Fetch WebAssembly binaries.

  • Whereas WeChat expects the argument passed to WebAssembly.instantiate

  • to be file path and the path should be relative from project’s root dir,

  • we do the path conversion and directly return the converted path.

  • @param path The path to .wasm file relative from engine’s out dir(no leading ./).

  • See ‘assetURLFormat’ field of build engine options.

*/

function fetchWasm(path) {

const engineDir = 'cocos-js'; // Relative from project out

return `${engineDir}/${path}`;

}

firstScreen.start(‘default’, ‘default’).then(() => {

return System.import('./application.js');

}).then((module) => {

return firstScreen.setProgress(0.2).then(() => Promise.resolve(module));

}).then(({ createApplication }) => {

return createApplication({

    loadJsListFile: (url) => require(url),

    fetchWasm,

});

}).then((application) => {

return firstScreen.setProgress(0.4).then(() => Promise.resolve(application));

}).then((application) => {

return onApplicationCreated(application);

}).catch((err) => {

console.error(err);

});

function onApplicationCreated(application) {

return application.import('cc').then((module) => {

    return firstScreen.setProgress(0.6).then(() => Promise.resolve(module));

}).then((cc) => {

    require('./libs/common/engine/index.js');

    require('./libs/wrapper/engine/index');

    require('./libs/common/cache-manager.js');

    // Adjust devicePixelRatio

    cc.view._maxPixelRatio = 4;

    // Release Image objects after uploaded gl texture

    cc.macro.CLEANUP_IMAGE_CACHE = false;

    return firstScreen.end().then(() => application.start({

        findCanvas: () => {

            var container = document.createElement('div');

            console.log('findCanvas', window.canvas.width, window.canvas.height);

            return { frame: container, canvas: window.canvas, container };

        },

    }));

});

}

1赞

蟹蟹,我试试