# Mini-Game Development Guide
Please Note
Starting from Base Library 2.11.6, the FinClip Mini-Program SDK has implemented support and runtime capabilities for mini-game projects. It currently supports mini-game projects exported directly from game engines such as Layabox, Egret, Cocosd-js, and unity.
If you need to adapt other game engines or require consultation assistance for mini-game projects, please provide feedback in the developer community or contact us at 0755-86967467.
# Mini-Game Directory Structure
A mini-game contains an app that describes the overall program.
The main part of a mini-game consists of two files, which must be placed in the project's root directory, as follows:
| File | Required | Purpose |
|---|---|---|
| game.js | Yes | Mini-game main logic, entry file |
| game.json | Yes | Mini-game public configuration |
| project.config.json | Yes | Project configuration file |
# Basic Capabilities
# Storage
Each Mini-Program can have its own local cache. You can read, write, and clear the local cache using ft.setStorage, ft.getStorage, ft.clearStorage, and ft.removeStorage.
# Rendering
# Canvas
A mini-game has only one on-screen canvas but can have multiple off-screen canvases. A canvas object can be created using wx.createCanvas.
# Drawing Context and Interfaces.
A drawing context can be created via Canvas.getContext. Refer to RenderingContext for the specific types of drawing contexts returned.
# Modularization
# Modularization
Mini-Programs currently do not support "directly importing node_modules". They need to be introduced by Building npm. If necessary, you can also directly copy the code into the Mini-Program's directory and then use it.
Note
exports is a reference to module.exports. Therefore, arbitrarily changing the reference of exports within a module may cause unknown errors. It is recommended that developers use module.exports to expose module interfaces unless you clearly understand the relationship between the two.
// common.js
function sayHello(name) {
console.log(`Hello Mini-Game Framework !`)
}
function sayGoodbye(name) {
console.log(`Goodbye Mini-Game Framework !`)
}
module.exports.sayHello = sayHello
exports.sayGoodbye = sayGoodbye
# Global Object
Similar to the browser's Window and NodeJS's global, a mini-game also has a global object called GameGlobal. Variables can be passed between multiple files via GameGlobal.
Tip
There is no window global object in mini-games. If needed, please mount data onto GameGlobal.
// a.js
GameGlobal.globalData = 1
// b.js
console.log(GameGlobal.globalData) // Outputs "1"
# Mini-Game DEMOs
Please Note
To assist you in debugging or utilizing mini-game related capabilities, we have collected and organized some open-source mini-game source codes from the internet for your testing purposes.
Please ensure you upgrade your current FinClip Studio to version 2.0.x or higher when using these. If you are using the import function in FinClip Studio to load a local directory, please make sure to change the project type to Mini-Game.
# 1. Tree Chopping Mini-Game
Source Code Link (opens new window)
# 2. WeChat Plane Battle
Source Code Link (opens new window)
# 3. Puzzle DEMO (Based on pixi.js)
Open the dist directory inside the zip file when running. Source Code Link (opens new window)
# 4. Room Escape DEMO (Based on egret)
Open the RoomRun_wxgame directory inside the zip file when running. Source Code Link (opens new window)
# 5. Tile-Matching Game, Taxi, Yang Le Ge Yang DEMOs (Based on Cocos)
Open the build/wechatgame directory inside the zip file when running.
- Cocos Circle Tile-Matching Game (opens new window)
- TaxiGame3D (opens new window)
- Yang Le Ge Yang DEMO (opens new window)