Build a WeChat Mini Game with Cocos Creator

Export a working Cocos Creator 3.8 scene as a WeChat Mini Game. Set the AppID, find the build folder, import it into WeChat DevTools and check the first screen.

Game Agent v0.4.3 Updated

Cocos Creator exports the game project. WeChat DevTools opens that export, compiles it and shows the result in its simulator. Start with a scene that already runs in Creator so you have a first screen to compare when you switch tools.

Start with a working scene

Open the Hello World example bundled with Cocos Creator 3.8.8 from Cocos Dashboard. Open assets/scene/main.scene and run Preview. With your own project, choose one action you can repeat, such as pressing Start to enter the game. For a new setup, see Download Cocos Creator and install Game Agent.

For a playable example with source code and four recorded development sessions, see the WeChat Jump project. Its entry scene is assets/scenes/JumpMain.scene. In desktop Preview, hold Space to charge and release it to jump.

Build for WeChat in Creator

  1. Open Project → Build, create a build task and choose WeChat Mini Game as the platform. Include the scene you previewed and select it as the start scene.
  2. Enter the AppID for your mini game, choose portrait or landscape, and click Build. The default AppID in the manual is for testing.
  3. Open the output folder from the finished build task. The default is build/wechatgame/. A custom task name or build path can change it. The folder contains game.json, which records options such as orientation, and project.config.json, whose appid should match the one you entered.

For the platform options and their effects, see the Cocos Creator 3.8 WeChat publishing manual.

We built the bundled Hello World project with Creator 3.8.8. The export contained the entry script game.js, with compileType set to game in project.config.json and deviceOrientation set to portrait in game.json. Check these fields against your own export. Our check covered the local build. Test the result on your target phone for device behavior.

Compile and preview in WeChat DevTools

Install WeChat DevTools from the official download page and open it once. In Creator, click Run on the finished build. You can also use Import in DevTools and select the export folder that directly contains project.config.json.

Compile in the simulator and compare the first screen with Creator Preview. If DevTools cannot find the project configuration, reopen the output folder from the build task. If a different scene appears, check the start scene and rebuild. When you are ready to test on a phone, select Preview, scan the code with a WeChat account that has preview access, and check touch input, orientation and the first load.

Test a gameplay change made with Game Agent

In your own project, ask Game Agent for one visible change, such as “Give the Start button a pressed state and keep its existing scene transition.” Click the button in Creator Preview, rebuild to the same folder, then compile again in DevTools and repeat the action.

To try the edit in your own scene, get the matching Game Agent plugin from the Cocos Store. Use the plugin to edit the scene and scripts, and the two platform tools above to build and preview the game.

Sources

Loading page views