1.关闭允许分离引擎
2.CocosDashboard_1.0.7\resources\.editors\Creator\2.4.3\resources\builtin\adapters\platforms\wechat\wrapper\builtin\Canvas.js
在Canvas.js
// 修改后
let first = true
export default function Canvas() {
const canvas = first ? wx.__first__canvas ? wx.__first__canvas : wx.createCanvas() : wx.createCanvas()
first = false
3.webgl_first_render.js网上下载
4.game.js文件添加
"use strict";
const { drawImg } = require('./webgl_first_render.js');
const data = wx.getSystemInfoSync();
wx.__first__canvas = data.platform != "devtools" ? wx.createCanvas() : null;
function render() {
if (data.platform != "devtools") {
if (wx.FIRSTRENDER) {
drawImg('bg.jpg', gl);
console.log("---------------------------render-------------------------")
requestAnimationFrame(render);
}else{
GameGlobal.dycc= null;
}
}
}
wx.FIRSTRENDER = true;
GameGlobal.dycc = wx.__first__canvas; //获取绘制二维上下文
var gl = data.platform != "devtools" ? GameGlobal.dycc.getContext("webgl") : null;
requestAnimationFrame(render);
require('adapter-min.js');
__globalAdapter.init();
require('cocos/cocos2d-js-min.js');
__globalAdapter.adaptEngine();
require('./ccRequire');
require('./src/settings'); // Introduce Cocos Service here
require('./main'); // TODO: move to common
// Adjust devicePixelRatio
cc.view._maxPixelRatio = 4;
if (cc.sys.platform !== cc.sys.WECHAT_GAME_SUB) {
// Release Image objects after uploaded gl texture
cc.macro.CLEANUP_IMAGE_CACHE = true;
}
window.boot();
5.main.js在加载完成后添加wx.FIRSTRENDER = false;
cc.director.loadScene(launchScene, null, function () {
console.log('Success to load scene: ' + launchScene);
wx.FIRSTRENDER = false;
});