OpenTGX updated 20240602

The latest repository for OPENTGX is available at:

If you find it helpful, please give us a star:

As a general framework, the OpenTGX version will develop with a focus on being small and elegant. It primarily addresses module management, UI management, and project collaboration issues.

Derivative cases of TGX will address more diverse application scenarios. Please check out the TGX series of works: Cocos Store

All friends developing products with OpenTGX, please get in touch with me to join the case library.

This update mainly includes usability improvements.

1. Added tgx_class decorator

Added the tgx_class(moduleName[, parentClassName]) decorator to register UI classes. The old tgxModuleContext.attachImplClass is deprecated. Now you only need to register like this:

// Standard UI
export class MyUI extends tgx.UIController {}

// UI with a superclass
@tgx_class('basic', SuperClass)
export class MyUI extends SuperClass {}

2. Support passing parameters when displaying UI

When calling tgx.UIMgr.inst.showUI, it supports passing custom parameters to facilitate UI initialization.

tgx.UIMgr.inst.showUI(MyUI, null, null, { a: 1, b: 2, c: 3 });

3. Removed import dependencies

No longer need to import tgx-related paths, making refactoring and code reuse more convenient. Please refer to tgx.ts for details.

4. Changed access method

Use tgx.xxxxx to access tgx-related classes, deprecating tgxXXXX:

  • tgxUIController → tgx.UIController
  • tgxUIMgr.inst.showUI → tgx.UIMgr.inst.showUI
  • →

5. Other various minor fixes

  • Changed ui.hide() to ui.close() to express that the UI will be destroyed after calling this method.
  • Fixed the issue where calling close before the UI successfully loads would fail to destroy the UI.
  • Replaced arrays with doubly linked lists to solve issues when removing UI and events during updates or callbacks.
  • Added the ignoreCloseAll flag to the UIController, allowing certain UIs to be displayed across scenes.

I hope everyone enjoys using COCOS and OpenTGX more and more.