Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

build: dragonbones is a target you can name, and ships where a scene needs it

yhhd03cba6d4d37
diff --git a/build-tools/build.config.js b/build-tools/build.config.js
index e880f4ed3..a18ef83da 100644
--- a/build-tools/build.config.js
+++ b/build-tools/build.config.js
@@ -175,6 +175,15 @@ export default {
'sdk/spine21.wasm': 'wasm/wechat/spine21.wasm',
},
},
+ 'dragonbones-wechat': {
+ buildDir: 'build-dragonbones-wechat',
+ cmakeFlags: ['-DES_BUILD_WXGAME=ON', '-DES_BUILD_TESTS=OFF', '-DES_ENABLE_DRAGONBONES=ON'],
+ targets: ['dragonbones_module'],
+ outputs: {
+ 'sdk/dragonbones.js': 'wasm/wechat/dragonbones.js',
+ 'sdk/dragonbones.wasm': 'wasm/wechat/dragonbones.wasm',
+ },
+ },
},
sdk: {
diff --git a/build-tools/cli.js b/build-tools/cli.js
index 5d08b9f7d..6365c1115 100644
--- a/build-tools/cli.js
+++ b/build-tools/cli.js
@@ -28,7 +28,7 @@ program
program
.command('build')
.description('Build ESEngine')
- .option('-t, --target <target>', 'Build target (web, wechat, spine, spine21, spine38, spine41, spine43, physics, physics-wechat, spine-wechat, basis, basis-wechat, sdk, all)', 'web')
+ .option('-t, --target <target>', 'Build target (web, wechat, spine, spine21, spine38, spine41, spine43, dragonbones, physics, physics-wechat, spine-wechat, dragonbones-wechat, basis, basis-wechat, sdk, all)', 'web')
.option('-d, --debug', 'Debug build', false)
.option('-r, --release', 'Release build (default)', true)
.option('-c, --clean', 'Clean before build', false)
@@ -52,7 +52,7 @@ program
const isDebug = options.debug && !options.release;
const targets = options.target === 'all'
- ? ['web', 'wechat', 'spine', 'spine21', 'spine38', 'spine41', 'spine43', 'physics', 'physics-wechat', 'spine-wechat', 'basis', 'basis-wechat', 'videodec', 'videodec-wechat']
+ ? ['web', 'wechat', 'spine', 'spine21', 'spine38', 'spine41', 'spine43', 'dragonbones', 'physics', 'physics-wechat', 'spine-wechat', 'dragonbones-wechat', 'basis', 'basis-wechat', 'videodec', 'videodec-wechat']
: [options.target];
if (options.clean) {
diff --git a/desktop/electron/buildPlayRealm.ts b/desktop/electron/buildPlayRealm.ts
index 0bc05b304..f22b05b8d 100644
--- a/desktop/electron/buildPlayRealm.ts
+++ b/desktop/electron/buildPlayRealm.ts
@@ -38,6 +38,7 @@ export const IMPORT_MAP = {
imports: {
esengine: './sdk/index.js',
'esengine/spine': './sdk/spine/index.js',
+ 'esengine/dragonbones': './sdk/dragonbones/index.js',
'esengine/physics': './sdk/physics/index.js',
'esengine/wasm': './sdk/wasm.js',
'esengine/factory': './sdk/webAppFactory.js',
diff --git a/desktop/electron/esengineResolve.ts b/desktop/electron/esengineResolve.ts
index 5c0e35c99..7be8a9cfd 100644
--- a/desktop/electron/esengineResolve.ts
+++ b/desktop/electron/esengineResolve.ts
@@ -26,6 +26,7 @@ export function esengineAlias(sdkDir: string, mainEntry = 'index.js'): Record<st
return {
esengine: path.join(sdkDir, mainEntry),
'esengine/spine': path.join(sdkDir, 'spine', 'index.js'),
+ 'esengine/dragonbones': path.join(sdkDir, 'dragonbones', 'index.js'),
'esengine/physics': path.join(sdkDir, 'physics', 'index.js'),
'esengine/wasm': path.join(sdkDir, 'wasm.js'),
'esengine/factory': path.join(sdkDir, 'webAppFactory.js'),
diff --git a/desktop/electron/exportMiniGame.ts b/desktop/electron/exportMiniGame.ts
index 5075bebbc..eec96a793 100644
--- a/desktop/electron/exportMiniGame.ts
+++ b/desktop/electron/exportMiniGame.ts
@@ -38,7 +38,7 @@ import type { ExportScene } from './exportGame';
import type { OnExportProgress } from './exportProgress';
import { esengineAlias } from './esengineResolve';
import {
- sceneUsesPhysics, sceneUsesVideo, detectSpineVersion, detectSpineVersionJson,
+ sceneUsesPhysics, sceneUsesVideo, sceneUsesDragonBones, detectSpineVersion, detectSpineVersionJson,
spineModuleId, SIDE_MODULE_FILE,
} from './sideModuleScan';
import type { MiniGameExportProfile, MiniGameVendor } from './miniGameExportProfile';
@@ -113,6 +113,7 @@ async function scanSideModules(
const ids = new Set<string>();
if (sceneDatas.some((s) => s && sceneUsesPhysics(s as Parameters<typeof sceneUsesPhysics>[0]))) ids.add('physics');
if (sceneDatas.some((s) => s && sceneUsesVideo(s as Parameters<typeof sceneUsesVideo>[0]))) ids.add('videodec');
+ if (sceneDatas.some((s) => s && sceneUsesDragonBones(s as Parameters<typeof sceneUsesDragonBones>[0]))) ids.add('dragonbones');
// Any staged .esv also needs the decoder: script-driven playback
// (VideoPlayer.play) references cooked videos no scene component names.
if (cookEntries.some((e) => /\.esv(\.bin)?$/.test(e.path.toLowerCase()))) ids.add('videodec');
diff --git a/desktop/electron/exportPlayable.ts b/desktop/electron/exportPlayable.ts
index de3f344f4..339ae98a5 100644
--- a/desktop/electron/exportPlayable.ts
+++ b/desktop/electron/exportPlayable.ts
@@ -27,7 +27,7 @@ import type { ScreenOrientation } from './orientationHtml';
import { genericPlayableProfile, playableAdInjection, type PlayableAdProfile } from './playableAdProfile';
import { makeZip } from '../../build-tools/utils/zip.js';
import {
- sceneUsesPhysics, detectSpineVersion, detectSpineVersionJson,
+ sceneUsesPhysics, sceneUsesDragonBones, detectSpineVersion, detectSpineVersionJson,
spineModuleId, SIDE_MODULE_FILE, type SpineVersion,
} from './sideModuleScan';
@@ -122,6 +122,7 @@ async function collectSideModules(
): Promise<Record<string, { glueBase64: string; wasmBase64: string }>> {
const ids = new Set<string>();
if (sceneData && sceneUsesPhysics(sceneData as Parameters<typeof sceneUsesPhysics>[0])) ids.add('physics');
+ if (sceneData && sceneUsesDragonBones(sceneData as Parameters<typeof sceneUsesDragonBones>[0])) ids.add('dragonbones');
// Spine: the skeleton carries the version. Skeleton + atlas share the authored
// meta type `spine`, so we discriminate by extension (as the runtime does via
// the asset-type registry's contentType) — `.skel` is a binary skeleton, `.json`
diff --git a/desktop/electron/sideModuleScan.ts b/desktop/electron/sideModuleScan.ts
index bb71ffdf0..ce7452539 100644
--- a/desktop/electron/sideModuleScan.ts
+++ b/desktop/electron/sideModuleScan.ts
@@ -35,6 +35,18 @@ export function sceneUsesPhysics(scene: SceneLike): boolean {
return false;
}
+/** True if any entity carries a DragonBonesAnimation. Unlike Spine there is no
+ * version to detect: the format is frozen and one module reads all of it, so the
+ * presence of the component IS the answer. */
+export function sceneUsesDragonBones(scene: SceneLike): boolean {
+ for (const entity of scene.entities ?? []) {
+ for (const comp of entity.components ?? []) {
+ if (comp.type === 'DragonBonesAnimation') return true;
+ }
+ }
+ return false;
+}
+
/** True if any entity carries a Video component — the wasm video decoder is
* WeChat's only video path, so any Video means the module must ship. */
export function sceneUsesVideo(scene: SceneLike): boolean {
@@ -73,6 +85,7 @@ export const SIDE_MODULE_FILE: Record<string, string> = {
physics: 'physics',
basis: 'basis',
videodec: 'videodec',
+ dragonbones: 'dragonbones',
'spine:2.1': 'spine21',
'spine:3.8': 'spine38',
'spine:4.1': 'spine41',
@@ -85,6 +98,7 @@ export const WECHAT_MODULE_BUILD_TARGET: Record<string, string> = {
physics: 'physics-wechat',
basis: 'basis-wechat',
videodec: 'videodec-wechat',
+ dragonbones: 'dragonbones-wechat',
'spine:2.1': 'spine-wechat',
'spine:3.8': 'spine-wechat',
'spine:4.1': 'spine-wechat',