Get the App
SLTechnology News&Howtos  ›  Development  › 

WeChat Mini Programs Mini Game development document how to write code

Shulou Source: shulou.com Published: 2022-06-01 06:02:15 09月29日 Update

This article mainly explains "WeChat Mini Programs Mini Game development document how to write code", the content of the article is simple and clear, easy to learn and understand, now please follow the editor's train of thought slowly in depth. Let's study and learn "WeChat Mini Programs Mini Game development document how to write code"!

Mini Game has only the following two necessary documents:

Game.js Mini Game main program entry

Game.json profile

Operation environment

Mini Game runs in an environment similar to Mini Program and runs in JavaScriptCore, so there is no DOM or BOM API.

Like Mini Program, Mini Game needs to be reviewed every time it is released. We have removed the ability to execute code dynamically in both Mini Program and Mini Game, including the following call methods:

Eval function

The first parameter of setTimeout and setInterval functions is passed into the code string for execution.

Pass in a string constructor using Function

Using GeneratorFunction to pass in strings to construct generator functions

HTML5 Game adaptation Guide

The existing HTML5 games want to be transplanted to Mini Game environment, and the following adaptations need to be made for Mini Game:

All DOM and BOM API are changed to the corresponding API call mode of Mini Game.

Avoid using the ability to execute code dynamically in a game

In the early stage, in order to reduce the cost of game migration, we provided an Adapter, which simulated and encapsulated a set of BOM and DOM API to the global environment based on the Mini Game environment.

Configuration item

Game Mini Program developers configure by writing a game.json file in the root directory, developer tools and clients need to read the configuration, complete the relevant interface rendering and property settings.

Sample configuration

{

"deviceOrientation": "portrait"

"networkTimeout": {

"request": 5000

"connectSocket": 5000

"uploadFile": 5000

"downloadFile": 5000

}

}

Thank you for your reading. the above is the content of "how to write code in WeChat Mini Programs Mini Game development document". After the study of this article, I believe you have a deeper understanding of how to write code in WeChat Mini Programs Mini Game development document. the specific use also needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Mini Game programs code development configuration documents functions environment characters strings files learning running content dynamic developers ways capabilities migration adaptation Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information vpn Shulou Tech Info Apple Microsoft