Skip to content

Table of Contents

Third - Party Scripts

Purpose

Customize the open capabilities of the 2J client.

Usage

Create a JS script and add functions for supported development capabilities to it. Then upload the script to 2J.

Supported Development Capabilities

  • apiCloseBrowserPage: void Close the page (this method will be called when the game triggers the closing of the game).
ts
function apiCloseBrowserPage() {
    /** Add the platform's own closing method here */
}

Performance Optimization Suggestions

  • When the client enters an API game, release unused memory as much as possible. For example:
    • The Cocos lobby should release lobby - related memory and recreate it when closing the API game.
  • When the client enters an API game, reduce unnecessary CPU consumption as much as possible. For example:
    • Pause the Cocos logic in the Cocos lobby using cc.game.pause(), and restart it using cc.game.resume() when closing the API game.

2J Game Inc.