CocosCreator WeChat Mini Game

Problem description:
I want to publish a mini game written with cocoscreator as a WeChat mini game. How to build and publish it?

1. Download WeChat developer tools first

Link: https://developers.weixin.qq.com/miniprogram/dev/devtools/stable.html
Insert image description here
Download the corresponding file according to your computer configuration.

2. Log in to WeChat developer tools

Open - WeChat Developer Tools -, log in with WeChat, click Mini Games, click the plus sign to add games.
Insert image description here
After registering - WeChat Developer Tools -, there will beAppID, can be added. If you haven't applied yet, you can click on the test number.
Table of contents: Add the file path after the game is built. Yeah, the game hasn't been built yet.

3. Build the game

Build according to the picture below and click Build.
Insert image description here

4. Continue to step 2

Fill in the file path after the game is built and enter WeChat debugging.
Insert image description here
Click on the preview and a QR code will appear. You can scan the code with your mobile phone and test it on your mobile phone.

5. Click Preview to report an error

If your package body is within 4096kb, the QR code can be generated smoothly. If it is greater than 4096, subcontracting is required.
WeChat development code subcontracting details
Limitation of subcontracting load package size
Currently, mini-game package sizes have the following restrictions:
: The size of all sub-packages of the entire mini-game does not exceed 20M
: There is no limit on the size of a single sub-package, and the main package does not exceed 4M

6. How to subcontract cocoscreator

For example: the game has three scenes, the first scene is the main package, and the other two scenes are sub-packaged.
Insert image description here
Fill in the second scene, third scene, and other resource folders according to the pictures below.
Bundle is bundled in folders.
Insert image description here
After building the game, the QR code can be generated smoothly.

7.How to use Bundle

For example: in the third scene, js will be loaded automatically when loading the third scene.

cc.assetManager.loadBundle("Bundle的文件名字",(err, bundle) => {
    
    
	bundle.load(["Bundle文件里的预制体1的名字","rule2"],cc.Prefab,(err,prefab)=>{
    
    
		let rule1Node = cc.instantiate(prefab[0]);	
		//Bundle文件里的预制体1	
		let rule1Node = cc.instantiate(prefab[1]);	
		//rule2 的节点被构建出来				
	});
});

The above is my own summary. If there is anything wrong, please point it out in the comments. Make changes when you see them.

Guess you like

Origin blog.csdn.net/m0_56414330/article/details/129911176
Recommended