Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

WeChat Mini Programs Mini Game development document how to write code

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report