@safe-engine/cocos 2.2.7 → 2.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/@types/index.d.ts +0 -61
  2. package/dist/app.d.ts +1 -1
  3. package/dist/app.d.ts.map +1 -1
  4. package/dist/app.js +25 -23
  5. package/dist/box2d-wasm/PhysicsComponent.d.ts +1 -1
  6. package/dist/box2d-wasm/PhysicsComponent.d.ts.map +1 -1
  7. package/dist/collider/CollideComponent.d.ts +21 -3
  8. package/dist/collider/CollideComponent.d.ts.map +1 -1
  9. package/dist/collider/CollideSystem.d.ts.map +1 -1
  10. package/dist/collider/CollideSystem.js +6 -5
  11. package/dist/core/EnhancedComponent.d.ts +1 -1
  12. package/dist/core/EnhancedComponent.d.ts.map +1 -1
  13. package/dist/core/NodeComp.d.ts +1 -1
  14. package/dist/core/NodeComp.d.ts.map +1 -1
  15. package/dist/dragonbones/DragonBonesComp.d.ts +27 -0
  16. package/dist/dragonbones/DragonBonesComp.d.ts.map +1 -0
  17. package/dist/dragonbones/DragonBonesComp.js +29 -0
  18. package/dist/dragonbones/DragonBonesSystem.d.ts +9 -0
  19. package/dist/dragonbones/DragonBonesSystem.d.ts.map +1 -0
  20. package/dist/dragonbones/DragonBonesSystem.js +69 -0
  21. package/dist/dragonbones/db-cocos/CocosArmatureDisplay.d.ts +87 -0
  22. package/dist/dragonbones/db-cocos/CocosArmatureDisplay.d.ts.map +1 -0
  23. package/dist/dragonbones/db-cocos/CocosArmatureDisplay.js +240 -0
  24. package/dist/dragonbones/db-cocos/CocosFactory.d.ts +128 -0
  25. package/dist/dragonbones/db-cocos/CocosFactory.d.ts.map +1 -0
  26. package/dist/dragonbones/db-cocos/CocosFactory.js +190 -0
  27. package/dist/dragonbones/db-cocos/CocosSlot.d.ts +49 -0
  28. package/dist/dragonbones/db-cocos/CocosSlot.d.ts.map +1 -0
  29. package/dist/dragonbones/db-cocos/CocosSlot.js +368 -0
  30. package/dist/dragonbones/db-cocos/CocosTextureAtlasData.d.ts +53 -0
  31. package/dist/dragonbones/db-cocos/CocosTextureAtlasData.d.ts.map +1 -0
  32. package/dist/dragonbones/db-cocos/CocosTextureAtlasData.js +121 -0
  33. package/dist/dragonbones/index.d.ts +1 -35
  34. package/dist/dragonbones/index.d.ts.map +1 -1
  35. package/dist/dragonbones/index.js +2 -83
  36. package/dist/gui/GUIComponent.d.ts +1 -1
  37. package/dist/gui/GUIComponent.d.ts.map +1 -1
  38. package/dist/index.d.ts +9 -2
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +0 -2
  41. package/dist/polyfills.d.ts +1 -1
  42. package/dist/polyfills.d.ts.map +1 -1
  43. package/dist/polyfills.js +1 -2
  44. package/dist/render/RenderComponent.d.ts +1 -1
  45. package/dist/render/RenderComponent.d.ts.map +1 -1
  46. package/dist/render/RenderComponent.js +1 -0
  47. package/dist/render/RenderSystem.d.ts.map +1 -1
  48. package/dist/render/RenderSystem.js +34 -2
  49. package/dist/richtext/RichTextComp.d.ts +1 -1
  50. package/dist/richtext/RichTextComp.d.ts.map +1 -1
  51. package/dist/richtext/RichTextComp.js +1 -1
  52. package/dist/spine/SpineSkeleton.d.ts +22 -0
  53. package/dist/spine/SpineSkeleton.d.ts.map +1 -0
  54. package/dist/spine/SpineSkeleton.js +18 -0
  55. package/dist/spine/SpineSystem.d.ts +6 -0
  56. package/dist/spine/SpineSystem.d.ts.map +1 -0
  57. package/dist/spine/SpineSystem.js +34 -0
  58. package/dist/spine/index.d.ts +1 -24
  59. package/dist/spine/index.d.ts.map +1 -1
  60. package/dist/spine/index.js +16 -42
  61. package/dist/spine/spine-cocos/CCSkeleton.d.ts +86 -0
  62. package/dist/spine/spine-cocos/CCSkeleton.d.ts.map +1 -0
  63. package/dist/spine/{CCSkeleton.js → spine-cocos/CCSkeleton.js} +39 -128
  64. package/dist/spine/spine-cocos/CCSkeletonAnimation.d.ts +87 -0
  65. package/dist/spine/spine-cocos/CCSkeletonAnimation.d.ts.map +1 -0
  66. package/dist/spine/{CCSkeletonAnimation.js → spine-cocos/CCSkeletonAnimation.js} +37 -97
  67. package/dist/spine/spine-cocos/CCSkeletonCanvasRenderCmd.d.ts +28 -0
  68. package/dist/spine/spine-cocos/CCSkeletonCanvasRenderCmd.d.ts.map +1 -0
  69. package/dist/spine/spine-cocos/CCSkeletonCanvasRenderCmd.js +224 -0
  70. package/dist/spine/{CCSkeletonTexture.d.ts → spine-cocos/CCSkeletonTexture.d.ts} +1 -1
  71. package/dist/spine/spine-cocos/CCSkeletonTexture.d.ts.map +1 -0
  72. package/dist/spine/{CCSkeletonTexture.js → spine-cocos/CCSkeletonTexture.js} +5 -5
  73. package/dist/spine/spine-cocos/CCSkeletonWebGLRenderCmd.d.ts.map +1 -0
  74. package/dist/spine/{CCSkeletonWebGLRenderCmd.js → spine-cocos/CCSkeletonWebGLRenderCmd.js} +13 -13
  75. package/package.json +5 -6
  76. package/dist/core/index.d.ts +0 -6
  77. package/dist/core/index.d.ts.map +0 -1
  78. package/dist/core/index.js +0 -5
  79. package/dist/dragonbones/PixiDragonBonesSprite.d.ts +0 -15
  80. package/dist/dragonbones/PixiDragonBonesSprite.d.ts.map +0 -1
  81. package/dist/dragonbones/PixiDragonBonesSprite.js +0 -71
  82. package/dist/gworld/EnhancedComponent.d.ts +0 -22
  83. package/dist/gworld/EnhancedComponent.d.ts.map +0 -1
  84. package/dist/gworld/EnhancedComponent.js +0 -44
  85. package/dist/gworld/NodeComp.d.ts +0 -153
  86. package/dist/gworld/NodeComp.d.ts.map +0 -1
  87. package/dist/gworld/NodeComp.js +0 -337
  88. package/dist/gworld/NodePool.d.ts +0 -9
  89. package/dist/gworld/NodePool.d.ts.map +0 -1
  90. package/dist/gworld/NodePool.js +0 -23
  91. package/dist/gworld/Scene.d.ts +0 -5
  92. package/dist/gworld/Scene.d.ts.map +0 -1
  93. package/dist/gworld/Scene.js +0 -14
  94. package/dist/gworld/decorator.d.ts +0 -8
  95. package/dist/gworld/decorator.d.ts.map +0 -1
  96. package/dist/gworld/decorator.js +0 -12
  97. package/dist/gworld/index.d.ts +0 -8
  98. package/dist/gworld/index.d.ts.map +0 -1
  99. package/dist/gworld/index.js +0 -14
  100. package/dist/render/TiledSprite.d.ts +0 -13
  101. package/dist/render/TiledSprite.d.ts.map +0 -1
  102. package/dist/render/TiledSprite.js +0 -69
  103. package/dist/safex.d.ts +0 -10
  104. package/dist/safex.d.ts.map +0 -1
  105. package/dist/safex.js +0 -25
  106. package/dist/spine/CCSkeleton.d.ts +0 -189
  107. package/dist/spine/CCSkeleton.d.ts.map +0 -1
  108. package/dist/spine/CCSkeletonAnimation.d.ts +0 -146
  109. package/dist/spine/CCSkeletonAnimation.d.ts.map +0 -1
  110. package/dist/spine/CCSkeletonCanvasRenderCmd.d.ts +0 -2
  111. package/dist/spine/CCSkeletonCanvasRenderCmd.d.ts.map +0 -1
  112. package/dist/spine/CCSkeletonCanvasRenderCmd.js +0 -228
  113. package/dist/spine/CCSkeletonTexture.d.ts.map +0 -1
  114. package/dist/spine/CCSkeletonWebGLRenderCmd.d.ts.map +0 -1
  115. package/dist/spine/PixiSpineSprite.d.ts +0 -15
  116. package/dist/spine/PixiSpineSprite.d.ts.map +0 -1
  117. package/dist/spine/PixiSpineSprite.js +0 -70
  118. /package/dist/spine/{CCSkeletonWebGLRenderCmd.d.ts → spine-cocos/CCSkeletonWebGLRenderCmd.d.ts} +0 -0
@@ -0,0 +1,240 @@
1
+ /**
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2012-2018 DragonBones team and other contributors
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
7
+ * this software and associated documentation files (the "Software"), to deal in
8
+ * the Software without restriction, including without limitation the rights to
9
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10
+ * the Software, and to permit persons to whom the Software is furnished to do so,
11
+ * subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ */
23
+ import { BoundingBoxType, DragonBones, } from '@cocos/dragonbones-js';
24
+ export class CocosArmatureDisplay extends cc.Sprite {
25
+ /**
26
+ * @private
27
+ */
28
+ debugDraw = false;
29
+ _debugDraw = false;
30
+ // private _disposeProxy: boolean = false;
31
+ _armature = null;
32
+ _debugDrawer = null;
33
+ // eventDispatcher: cc.EventManager = null as any;
34
+ listenerCount = {};
35
+ events = {};
36
+ constructor() {
37
+ // 1. super init first
38
+ super();
39
+ super.ctor(); // always call this for compatibility with cocos2dx JS Javascript class system
40
+ // this.eventDispatcher = cc.eventManager;
41
+ }
42
+ hasEvent(type) {
43
+ return this.hasDBEventListener(type);
44
+ }
45
+ addEvent(type, listener, thisObject) {
46
+ // console.log('addEvent', type, listener, thisObject);
47
+ this.addDBEventListener(type, listener, thisObject);
48
+ }
49
+ removeEvent(type, listener, thisObject) {
50
+ this.removeDBEventListener(type, listener, thisObject);
51
+ }
52
+ /**
53
+ * @inheritDoc
54
+ */
55
+ dbInit(armature) {
56
+ this._armature = armature;
57
+ }
58
+ /**
59
+ * @inheritDoc
60
+ */
61
+ dbClear() {
62
+ if (this._debugDrawer !== null) {
63
+ this._debugDrawer.removeFromParent();
64
+ }
65
+ this._armature = null;
66
+ this._debugDrawer = null;
67
+ super.removeFromParent();
68
+ }
69
+ /**
70
+ * @inheritDoc
71
+ */
72
+ dbUpdate() {
73
+ const drawed = DragonBones.debugDraw || this.debugDraw;
74
+ if (drawed || this._debugDraw) {
75
+ this._debugDraw = drawed;
76
+ if (this._debugDraw) {
77
+ if (this._debugDrawer === null) {
78
+ this._debugDrawer = new cc.Sprite();
79
+ const boneDrawer = new cc.DrawNode();
80
+ this._debugDrawer.addChild(boneDrawer);
81
+ }
82
+ this.addChild(this._debugDrawer);
83
+ const boneDrawer = this._debugDrawer.children[0];
84
+ boneDrawer.clear();
85
+ const bones = this._armature.getBones();
86
+ for (let i = 0, l = bones.length; i < l; ++i) {
87
+ const bone = bones[i];
88
+ const boneLength = bone.boneData.length;
89
+ const startX = bone.globalTransformMatrix.tx;
90
+ const startY = bone.globalTransformMatrix.ty;
91
+ const endX = startX + bone.globalTransformMatrix.a * boneLength;
92
+ const endY = startY + bone.globalTransformMatrix.b * boneLength;
93
+ boneDrawer.setLineWidth(2.0);
94
+ boneDrawer.setColor(cc.color('0x00FFFF'));
95
+ boneDrawer.drawSegment(cc.p(startX, startY), cc.p(endX, endY));
96
+ // boneDrawer.lineStyle(0.0, 0, 0.0);
97
+ // boneDrawer.beginFill(0x00FFFF, 0.7);
98
+ boneDrawer.drawCircle(cc.p(startX, startY), 3.0, Math.PI * 2, 64);
99
+ // boneDrawer.endFill();
100
+ }
101
+ const slots = this._armature.getSlots();
102
+ for (let i = 0, l = slots.length; i < l; ++i) {
103
+ const slot = slots[i];
104
+ const boundingBoxData = slot.boundingBoxData;
105
+ if (boundingBoxData) {
106
+ let child = this._debugDrawer.getChildByName(slot.name);
107
+ if (!child) {
108
+ child = new cc.DrawNode();
109
+ child.setName(slot.name);
110
+ this._debugDrawer.addChild(child);
111
+ }
112
+ child.clear();
113
+ child.setLineWidth(2.0);
114
+ child.setColor(cc.color('0xFF00FF'));
115
+ child.setOpacity(0.7);
116
+ // child.lineStyle(2.0, 0xff00ff, 0.7);
117
+ switch (boundingBoxData.type) {
118
+ case BoundingBoxType.Rectangle:
119
+ child.drawRect(cc.p(-boundingBoxData.width * 0.5, -boundingBoxData.height * 0.5), cc.p(boundingBoxData.width * 0.5, boundingBoxData.height * 0.5));
120
+ break;
121
+ case BoundingBoxType.Ellipse:
122
+ child.drawCircle(cc.p(0.0, 0.0), boundingBoxData.width * 0.5, 0, 64);
123
+ // -boundingBoxData.width * 0.5,
124
+ // -boundingBoxData.height * 0.5,
125
+ // boundingBoxData.width,
126
+ // boundingBoxData.height
127
+ // );
128
+ break;
129
+ case BoundingBoxType.Polygon: {
130
+ const { vertices } = boundingBoxData;
131
+ const points = [];
132
+ for (let i = 0, l = vertices.length; i < l; i += 2) {
133
+ const x = vertices[i];
134
+ const y = vertices[i + 1];
135
+ // if (i === 0) {
136
+ // child.moveTo(x, y);
137
+ // } else {
138
+ // child.lineTo(x, y);
139
+ // }
140
+ // child.drawSegment(cc.p(x, y), cc.p(vertices[i + 2], vertices[i + 3]));
141
+ points.push(cc.p(x, y));
142
+ }
143
+ // child.lineTo(vertices[0], vertices[1]);
144
+ child.drawPoly(points);
145
+ break;
146
+ }
147
+ default:
148
+ break;
149
+ }
150
+ // child.endFill();
151
+ slot.updateTransformAndMatrix();
152
+ slot.updateGlobalTransform();
153
+ const transform = slot.global;
154
+ child.setTransform(transform.x, transform.y, transform.scaleX, transform.scaleY, transform.rotation, transform.skew, 0.0, slot._pivotX, slot._pivotY);
155
+ }
156
+ else {
157
+ const child = this._debugDrawer.getChildByName(slot.name);
158
+ if (child) {
159
+ this._debugDrawer.removeChild(child);
160
+ }
161
+ }
162
+ }
163
+ }
164
+ else if (this._debugDrawer !== null && this._debugDrawer.parent === this) {
165
+ this.removeChild(this._debugDrawer);
166
+ }
167
+ }
168
+ }
169
+ /**
170
+ * @inheritDoc
171
+ */
172
+ dispose(disposeProxy = true) {
173
+ // disposeProxy;
174
+ if (this._armature !== null) {
175
+ this._armature.dispose();
176
+ this._armature = null;
177
+ }
178
+ }
179
+ /**
180
+ * @inheritDoc
181
+ */
182
+ destroy() {
183
+ this.dispose();
184
+ }
185
+ /**
186
+ * @private
187
+ */
188
+ dispatchDBEvent(type, eventObject) {
189
+ // console.log('dispatchDBEvent', type, eventObject);
190
+ // this.eventDispatcher.dispatchCustomEvent(type, eventObject);
191
+ if (this.events[type]) {
192
+ const ev = new cc.EventCustom(type);
193
+ ev.setUserData(eventObject);
194
+ this.events[type].forEach((fc) => fc(ev));
195
+ }
196
+ }
197
+ /**
198
+ * @inheritDoc
199
+ */
200
+ hasDBEventListener(type) {
201
+ // console.log('hasDBEventListener', type);
202
+ return (this.listenerCount[type] || 0) > 0;
203
+ // return this.eventDispatcher.isEnabled();
204
+ }
205
+ /**
206
+ * @inheritDoc
207
+ */
208
+ addDBEventListener(type, listener, target) {
209
+ // console.log('addDBEventListener', type);
210
+ this.listenerCount[type] = (this.listenerCount[type] || 0) + 1;
211
+ // this.eventDispatcher.addCustomListener(type, listener.bind(target));
212
+ const bound = target ? listener.bind(target) : listener;
213
+ if (this.events[type]) {
214
+ this.events[type].push(bound);
215
+ }
216
+ else {
217
+ this.events[type] = [bound];
218
+ }
219
+ }
220
+ /**
221
+ * @inheritDoc
222
+ */
223
+ removeDBEventListener(type, listener, target) {
224
+ this.listenerCount[type] = (this.listenerCount[type] || 0) - 1;
225
+ // this.eventDispatcher.removeCustomListeners(type);
226
+ this.events[type] = undefined;
227
+ }
228
+ /**
229
+ * @inheritDoc
230
+ */
231
+ get armature() {
232
+ return this._armature;
233
+ }
234
+ /**
235
+ * @inheritDoc
236
+ */
237
+ get animation() {
238
+ return this._armature.animation;
239
+ }
240
+ }
@@ -0,0 +1,128 @@
1
+ /**
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2012-2018 DragonBones team and other contributors
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
7
+ * this software and associated documentation files (the "Software"), to deal in
8
+ * the Software without restriction, including without limitation the rights to
9
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10
+ * the Software, and to permit persons to whom the Software is furnished to do so,
11
+ * subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ */
23
+ import { Armature, BaseFactory, BuildArmaturePackage, DataParser, DisplayData, Slot, SlotData } from '@cocos/dragonbones-js';
24
+ import { CocosArmatureDisplay } from './CocosArmatureDisplay';
25
+ import { CocosTextureAtlasData } from './CocosTextureAtlasData';
26
+ /**
27
+ * - The PixiJS factory.
28
+ * @version DragonBones 3.0
29
+ * @language en_US
30
+ */
31
+ /**
32
+ * - PixiJS 工厂。
33
+ * @version DragonBones 3.0
34
+ * @language zh_CN
35
+ */
36
+ export declare class CocosFactory extends BaseFactory {
37
+ private static _dragonBonesInstance;
38
+ private static _factory;
39
+ private static _clockHandler;
40
+ static advanceTime(passedTime: number): void;
41
+ static useSharedTicker: boolean;
42
+ /**
43
+ * - A global factory instance that can be used directly.
44
+ * @version DragonBones 4.7
45
+ * @language en_US
46
+ */
47
+ /**
48
+ * - 一个可以直接使用的全局工厂实例。
49
+ * @version DragonBones 4.7
50
+ * @language zh_CN
51
+ */
52
+ static get factory(): CocosFactory;
53
+ /**
54
+ * - 一个获取全局工厂实例(单例)的方法, 和get factory相比, 优点是可以传参数。
55
+ * @version DragonBones 4.7
56
+ * @language zh_CN
57
+ */
58
+ static newInstance(): CocosFactory;
59
+ /**
60
+ * @inheritDoc
61
+ */
62
+ constructor(dataParser?: DataParser | null);
63
+ protected _buildTextureAtlasData(textureAtlasData: CocosTextureAtlasData | null, textureAtlas: cc.Texture2D | null): CocosTextureAtlasData;
64
+ protected _buildArmature(dataPackage: BuildArmaturePackage): Armature;
65
+ protected _buildSlot(_dataPackage: BuildArmaturePackage, slotData: SlotData, armature: DisplayData[]): Slot;
66
+ /**
67
+ * - Create a armature from cached DragonBonesData instances and TextureAtlasData instances, then use the {@link #clock} to update it.
68
+ * The difference is that the armature created by {@link #buildArmature} is not WorldClock instance update.
69
+ * @param armatureName - The armature data name.
70
+ * @param dragonBonesName - The cached name of the DragonBonesData instance. (If not set, all DragonBonesData instances are retrieved, and when multiple DragonBonesData instances contain a the same name armature data, it may not be possible to accurately create a specific armature)
71
+ * @param skinName - The skin name, you can set a different ArmatureData name to share it's skin data. (If not set, use the default skin data)
72
+ * @returns The armature display container.
73
+ * @see dragonBones.IArmatureProxy
74
+ * @see dragonBones.BaseFactory#buildArmature
75
+ * @version DragonBones 4.5
76
+ * @example
77
+ * <pre>
78
+ * let armatureDisplay = factory.buildArmatureDisplay("armatureName", "dragonBonesName");
79
+ * </pre>
80
+ * @language en_US
81
+ */
82
+ /**
83
+ * - 通过缓存的 DragonBonesData 实例和 TextureAtlasData 实例创建一个骨架,并用 {@link #clock} 更新该骨架。
84
+ * 区别在于由 {@link #buildArmature} 创建的骨架没有 WorldClock 实例驱动。
85
+ * @param armatureName - 骨架数据名称。
86
+ * @param dragonBonesName - DragonBonesData 实例的缓存名称。 (如果未设置,将检索所有的 DragonBonesData 实例,当多个 DragonBonesData 实例中包含同名的骨架数据时,可能无法准确的创建出特定的骨架)
87
+ * @param skinName - 皮肤名称,可以设置一个其他骨架数据名称来共享其皮肤数据。 (如果未设置,则使用默认的皮肤数据)
88
+ * @returns 骨架的显示容器。
89
+ * @see dragonBones.IArmatureProxy
90
+ * @see dragonBones.BaseFactory#buildArmature
91
+ * @version DragonBones 4.5
92
+ * @example
93
+ * <pre>
94
+ * let armatureDisplay = factory.buildArmatureDisplay("armatureName", "dragonBonesName");
95
+ * </pre>
96
+ * @language zh_CN
97
+ */
98
+ buildArmatureDisplay(armatureName: string, dragonBonesName?: string, skinName?: string, textureAtlasName?: string): CocosArmatureDisplay | null;
99
+ /**
100
+ * - Create the display object with the specified texture.
101
+ * @param textureName - The texture data name.
102
+ * @param textureAtlasName - The texture atlas data name (Of not set, all texture atlas data will be searched)
103
+ * @version DragonBones 3.0
104
+ * @language en_US
105
+ */
106
+ /**
107
+ * - 创建带有指定贴图的显示对象。
108
+ * @param textureName - 贴图数据名称。
109
+ * @param textureAtlasName - 贴图集数据名称。 (如果未设置,将检索所有的贴图集数据)
110
+ * @version DragonBones 3.0
111
+ * @language zh_CN
112
+ */
113
+ getTextureDisplay(textureName: string, textureAtlasName?: string | null): cc.Sprite | null;
114
+ /**
115
+ * - A global sound event manager.
116
+ * Sound events can be listened to uniformly from the manager.
117
+ * @version DragonBones 4.5
118
+ * @language en_US
119
+ */
120
+ /**
121
+ * - 全局声音事件管理器。
122
+ * 声音事件可以从该管理器统一侦听。
123
+ * @version DragonBones 4.5
124
+ * @language zh_CN
125
+ */
126
+ get soundEventManager(): CocosArmatureDisplay;
127
+ }
128
+ //# sourceMappingURL=CocosFactory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CocosFactory.d.ts","sourceRoot":"","sources":["../../../src/dragonbones/db-cocos/CocosFactory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EACL,QAAQ,EACR,WAAW,EAEX,oBAAoB,EACpB,UAAU,EACV,WAAW,EAEX,IAAI,EACJ,QAAQ,EACT,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAE7D,OAAO,EAAE,qBAAqB,EAAoB,MAAM,yBAAyB,CAAA;AAEjF;;;;GAIG;AACH;;;;GAIG;AACH,qBAAa,YAAa,SAAQ,WAAW;IAC3C,OAAO,CAAC,MAAM,CAAC,oBAAoB,CAA2B;IAC9D,OAAO,CAAC,MAAM,CAAC,QAAQ,CAA4B;IACnD,OAAO,CAAC,MAAM,CAAC,aAAa;WAOd,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAOnD,OAAc,eAAe,UAAO;IAEpC;;;;OAIG;IACH;;;;OAIG;IACH,WAAkB,OAAO,IAAI,YAAY,CAMxC;IAED;;;;OAIG;WACW,WAAW,IAAI,YAAY;IAOzC;;OAEG;gBACgB,UAAU,GAAE,UAAU,GAAG,IAAW;IAWvD,SAAS,CAAC,sBAAsB,CAC9B,gBAAgB,EAAE,qBAAqB,GAAG,IAAI,EAC9C,YAAY,EAAE,EAAE,CAAC,SAAS,GAAG,IAAI,GAChC,qBAAqB;IAaxB,SAAS,CAAC,cAAc,CAAC,WAAW,EAAE,oBAAoB,GAAG,QAAQ;IASrE,SAAS,CAAC,UAAU,CAAC,YAAY,EAAE,oBAAoB,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,IAAI;IAM3G;;;;;;;;;;;;;;;OAeG;IACH;;;;;;;;;;;;;;;OAeG;IACI,oBAAoB,CACzB,YAAY,EAAE,MAAM,EACpB,eAAe,SAAK,EACpB,QAAQ,SAAK,EACb,gBAAgB,SAAK,GACpB,oBAAoB,GAAG,IAAI;IAU9B;;;;;;OAMG;IACH;;;;;;OAMG;IACI,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,gBAAgB,GAAE,MAAM,GAAG,IAAW,GAAG,EAAE,CAAC,MAAM,GAAG,IAAI;IAQvG;;;;;OAKG;IACH;;;;;OAKG;IACH,IAAW,iBAAiB,IAAI,oBAAoB,CAEnD;CACF"}
@@ -0,0 +1,190 @@
1
+ /**
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2012-2018 DragonBones team and other contributors
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
7
+ * this software and associated documentation files (the "Software"), to deal in
8
+ * the Software without restriction, including without limitation the rights to
9
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10
+ * the Software, and to permit persons to whom the Software is furnished to do so,
11
+ * subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ */
23
+ import { Armature, BaseFactory, BaseObject, DragonBones, } from '@cocos/dragonbones-js';
24
+ import { CocosArmatureDisplay } from './CocosArmatureDisplay';
25
+ import { CocosSlot } from './CocosSlot';
26
+ import { CocosTextureAtlasData } from './CocosTextureAtlasData';
27
+ /**
28
+ * - The PixiJS factory.
29
+ * @version DragonBones 3.0
30
+ * @language en_US
31
+ */
32
+ /**
33
+ * - PixiJS 工厂。
34
+ * @version DragonBones 3.0
35
+ * @language zh_CN
36
+ */
37
+ export class CocosFactory extends BaseFactory {
38
+ static _dragonBonesInstance = null;
39
+ static _factory = null;
40
+ static _clockHandler(passedTime) {
41
+ this._dragonBonesInstance.advanceTime(passedTime);
42
+ }
43
+ /*
44
+ * `passedTime` is elapsed time, specified in seconds.
45
+ */
46
+ static advanceTime(passedTime) {
47
+ this._dragonBonesInstance.advanceTime(passedTime);
48
+ }
49
+ /*
50
+ * whether use `PIXI.Ticker.shared`
51
+ */
52
+ static useSharedTicker = true;
53
+ /**
54
+ * - A global factory instance that can be used directly.
55
+ * @version DragonBones 4.7
56
+ * @language en_US
57
+ */
58
+ /**
59
+ * - 一个可以直接使用的全局工厂实例。
60
+ * @version DragonBones 4.7
61
+ * @language zh_CN
62
+ */
63
+ static get factory() {
64
+ if (CocosFactory._factory === null) {
65
+ CocosFactory._factory = new CocosFactory(null);
66
+ }
67
+ return CocosFactory._factory;
68
+ }
69
+ /**
70
+ * - 一个获取全局工厂实例(单例)的方法, 和get factory相比, 优点是可以传参数。
71
+ * @version DragonBones 4.7
72
+ * @language zh_CN
73
+ */
74
+ static newInstance() {
75
+ if (CocosFactory._factory === null) {
76
+ CocosFactory._factory = new CocosFactory(null);
77
+ }
78
+ return CocosFactory._factory;
79
+ }
80
+ /**
81
+ * @inheritDoc
82
+ */
83
+ constructor(dataParser = null) {
84
+ super(dataParser);
85
+ if (CocosFactory._dragonBonesInstance === null) {
86
+ const eventManager = new CocosArmatureDisplay();
87
+ CocosFactory._dragonBonesInstance = new DragonBones(eventManager);
88
+ }
89
+ this._dragonBones = CocosFactory._dragonBonesInstance;
90
+ }
91
+ _buildTextureAtlasData(textureAtlasData, textureAtlas) {
92
+ if (textureAtlasData) {
93
+ // console.log(textureAtlasData, 'textureAtlasData', textureAtlas)
94
+ const scale = cc.director.getContentScaleFactor();
95
+ textureAtlasData.scale = scale;
96
+ textureAtlasData.renderTexture = textureAtlas;
97
+ }
98
+ else {
99
+ textureAtlasData = BaseObject.borrowObject(CocosTextureAtlasData);
100
+ }
101
+ return textureAtlasData;
102
+ }
103
+ _buildArmature(dataPackage) {
104
+ const armature = BaseObject.borrowObject(Armature);
105
+ const armatureDisplay = new CocosArmatureDisplay();
106
+ armature.init(dataPackage.armature, armatureDisplay, armatureDisplay, this._dragonBones);
107
+ return armature;
108
+ }
109
+ _buildSlot(_dataPackage, slotData, armature) {
110
+ const slot = BaseObject.borrowObject(CocosSlot);
111
+ slot.init(slotData, armature, new cc.Sprite(), new cc.Sprite());
112
+ return slot;
113
+ }
114
+ /**
115
+ * - Create a armature from cached DragonBonesData instances and TextureAtlasData instances, then use the {@link #clock} to update it.
116
+ * The difference is that the armature created by {@link #buildArmature} is not WorldClock instance update.
117
+ * @param armatureName - The armature data name.
118
+ * @param dragonBonesName - The cached name of the DragonBonesData instance. (If not set, all DragonBonesData instances are retrieved, and when multiple DragonBonesData instances contain a the same name armature data, it may not be possible to accurately create a specific armature)
119
+ * @param skinName - The skin name, you can set a different ArmatureData name to share it's skin data. (If not set, use the default skin data)
120
+ * @returns The armature display container.
121
+ * @see dragonBones.IArmatureProxy
122
+ * @see dragonBones.BaseFactory#buildArmature
123
+ * @version DragonBones 4.5
124
+ * @example
125
+ * <pre>
126
+ * let armatureDisplay = factory.buildArmatureDisplay("armatureName", "dragonBonesName");
127
+ * </pre>
128
+ * @language en_US
129
+ */
130
+ /**
131
+ * - 通过缓存的 DragonBonesData 实例和 TextureAtlasData 实例创建一个骨架,并用 {@link #clock} 更新该骨架。
132
+ * 区别在于由 {@link #buildArmature} 创建的骨架没有 WorldClock 实例驱动。
133
+ * @param armatureName - 骨架数据名称。
134
+ * @param dragonBonesName - DragonBonesData 实例的缓存名称。 (如果未设置,将检索所有的 DragonBonesData 实例,当多个 DragonBonesData 实例中包含同名的骨架数据时,可能无法准确的创建出特定的骨架)
135
+ * @param skinName - 皮肤名称,可以设置一个其他骨架数据名称来共享其皮肤数据。 (如果未设置,则使用默认的皮肤数据)
136
+ * @returns 骨架的显示容器。
137
+ * @see dragonBones.IArmatureProxy
138
+ * @see dragonBones.BaseFactory#buildArmature
139
+ * @version DragonBones 4.5
140
+ * @example
141
+ * <pre>
142
+ * let armatureDisplay = factory.buildArmatureDisplay("armatureName", "dragonBonesName");
143
+ * </pre>
144
+ * @language zh_CN
145
+ */
146
+ buildArmatureDisplay(armatureName, dragonBonesName = '', skinName = '', textureAtlasName = '') {
147
+ const armature = this.buildArmature(armatureName, dragonBonesName || '', skinName || '', textureAtlasName || '');
148
+ if (armature !== null) {
149
+ this._dragonBones.clock.add(armature);
150
+ return armature.display;
151
+ }
152
+ return null;
153
+ }
154
+ /**
155
+ * - Create the display object with the specified texture.
156
+ * @param textureName - The texture data name.
157
+ * @param textureAtlasName - The texture atlas data name (Of not set, all texture atlas data will be searched)
158
+ * @version DragonBones 3.0
159
+ * @language en_US
160
+ */
161
+ /**
162
+ * - 创建带有指定贴图的显示对象。
163
+ * @param textureName - 贴图数据名称。
164
+ * @param textureAtlasName - 贴图集数据名称。 (如果未设置,将检索所有的贴图集数据)
165
+ * @version DragonBones 3.0
166
+ * @language zh_CN
167
+ */
168
+ getTextureDisplay(textureName, textureAtlasName = null) {
169
+ const textureData = this._getTextureData(textureAtlasName !== null ? textureAtlasName : '', textureName);
170
+ if (textureData !== null && textureData.renderTexture !== null) {
171
+ return new cc.Sprite(textureData.renderTexture);
172
+ }
173
+ return null;
174
+ }
175
+ /**
176
+ * - A global sound event manager.
177
+ * Sound events can be listened to uniformly from the manager.
178
+ * @version DragonBones 4.5
179
+ * @language en_US
180
+ */
181
+ /**
182
+ * - 全局声音事件管理器。
183
+ * 声音事件可以从该管理器统一侦听。
184
+ * @version DragonBones 4.5
185
+ * @language zh_CN
186
+ */
187
+ get soundEventManager() {
188
+ return this._dragonBones.eventManager;
189
+ }
190
+ }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2012-2018 DragonBones team and other contributors
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
7
+ * this software and associated documentation files (the "Software"), to deal in
8
+ * the Software without restriction, including without limitation the rights to
9
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10
+ * the Software, and to permit persons to whom the Software is furnished to do so,
11
+ * subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ */
23
+ import { Slot } from '@cocos/dragonbones-js';
24
+ export declare class CocosSlot extends Slot {
25
+ _updateGlueMesh(): void;
26
+ static toString(): string;
27
+ private _textureScale;
28
+ private _renderDisplay;
29
+ protected _onClear(): void;
30
+ protected _initDisplay(value: any, isRetain: boolean): void;
31
+ protected _disposeDisplay(value: any, isRelease: boolean): void;
32
+ protected _onUpdateDisplay(): void;
33
+ protected _addDisplay(): void;
34
+ protected _replaceDisplay(value: any): void;
35
+ protected _removeDisplay(): void;
36
+ protected _updateZOrder(): void;
37
+ /**
38
+ * @internal
39
+ */
40
+ _updateVisible(): void;
41
+ protected _updateBlendMode(): void;
42
+ protected _updateColor(): void;
43
+ protected _updateFrame(): void;
44
+ protected _updateMesh(): void;
45
+ protected _updateTransform(): void;
46
+ protected _updateTransformV3(): void;
47
+ protected _identityTransform(): void;
48
+ }
49
+ //# sourceMappingURL=CocosSlot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CocosSlot.d.ts","sourceRoot":"","sources":["../../../src/dragonbones/db-cocos/CocosSlot.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAsC,IAAI,EAAa,MAAM,uBAAuB,CAAA;AAK3F,qBAAa,SAAU,SAAQ,IAAI;IACjC,eAAe,IAAI,IAAI;WACT,QAAQ,IAAI,MAAM;IAIhC,OAAO,CAAC,aAAa,CAAQ;IAC7B,OAAO,CAAC,cAAc,CAAS;IAE/B,SAAS,CAAC,QAAQ,IAAI,IAAI;IAQ1B,SAAS,CAAC,YAAY,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,GAAG,IAAI;IAO3D,SAAS,CAAC,eAAe,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,GAAG,IAAI;IAQ/D,SAAS,CAAC,gBAAgB,IAAI,IAAI;IAIlC,SAAS,CAAC,WAAW,IAAI,IAAI;IAK7B,SAAS,CAAC,eAAe,CAAC,KAAK,EAAE,GAAG,GAAG,IAAI;IAS3C,SAAS,CAAC,cAAc,IAAI,IAAI;IAIhC,SAAS,CAAC,aAAa,IAAI,IAAI;IAO/B;;OAEG;IACI,cAAc,IAAI,IAAI;IAI7B,SAAS,CAAC,gBAAgB,IAAI,IAAI;IAMlC,SAAS,CAAC,YAAY,IAAI,IAAI;IAc9B,SAAS,CAAC,YAAY,IAAI,IAAI;IAwG9B,SAAS,CAAC,WAAW,IAAI,IAAI;IAyJ7B,SAAS,CAAC,gBAAgB,IAAI,IAAI;IAqBlC,SAAS,CAAC,kBAAkB,IAAI,IAAI;IAuBpC,SAAS,CAAC,kBAAkB,IAAI,IAAI;CAiBrC"}