@safe-engine/cocos 2.2.8 → 2.3.5

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 (78) hide show
  1. package/@types/index.d.ts +0 -59
  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.map +1 -1
  6. package/dist/box2d-wasm/PhysicsComponent.js +3 -0
  7. package/dist/box2d-wasm/PhysicsSprite.d.ts.map +1 -1
  8. package/dist/box2d-wasm/PhysicsSprite.js +2 -1
  9. package/dist/box2d-wasm/PhysicsSystem.d.ts +1 -0
  10. package/dist/box2d-wasm/PhysicsSystem.d.ts.map +1 -1
  11. package/dist/box2d-wasm/PhysicsSystem.js +20 -16
  12. package/dist/box2d-wasm/debugDraw.d.ts +0 -15
  13. package/dist/box2d-wasm/debugDraw.d.ts.map +1 -1
  14. package/dist/box2d-wasm/debugDraw.js +8 -20
  15. package/dist/box2d-wasm/index.d.ts +19 -1
  16. package/dist/box2d-wasm/index.d.ts.map +1 -1
  17. package/dist/box2d-wasm/index.js +2 -2
  18. package/dist/collider/CollideComponent.d.ts +21 -3
  19. package/dist/collider/CollideComponent.d.ts.map +1 -1
  20. package/dist/core/NodeComp.d.ts +1 -1
  21. package/dist/core/NodeComp.d.ts.map +1 -1
  22. package/dist/dragonbones/DragonBonesComp.d.ts +4 -6
  23. package/dist/dragonbones/DragonBonesComp.d.ts.map +1 -1
  24. package/dist/dragonbones/DragonBonesComp.js +15 -13
  25. package/dist/dragonbones/DragonBonesSystem.d.ts +1 -1
  26. package/dist/dragonbones/DragonBonesSystem.d.ts.map +1 -1
  27. package/dist/dragonbones/DragonBonesSystem.js +42 -35
  28. package/dist/dragonbones/db-cocos/CocosArmatureDisplay.d.ts +87 -0
  29. package/dist/dragonbones/db-cocos/CocosArmatureDisplay.d.ts.map +1 -0
  30. package/dist/dragonbones/db-cocos/CocosArmatureDisplay.js +240 -0
  31. package/dist/dragonbones/db-cocos/CocosFactory.d.ts +127 -0
  32. package/dist/dragonbones/db-cocos/CocosFactory.d.ts.map +1 -0
  33. package/dist/dragonbones/db-cocos/CocosFactory.js +186 -0
  34. package/dist/dragonbones/db-cocos/CocosSlot.d.ts +52 -0
  35. package/dist/dragonbones/db-cocos/CocosSlot.d.ts.map +1 -0
  36. package/dist/dragonbones/db-cocos/CocosSlot.js +365 -0
  37. package/dist/dragonbones/db-cocos/CocosTextureAtlasData.d.ts +53 -0
  38. package/dist/dragonbones/db-cocos/CocosTextureAtlasData.d.ts.map +1 -0
  39. package/dist/dragonbones/db-cocos/CocosTextureAtlasData.js +121 -0
  40. package/dist/dragonbones/db-cocos/SimpleMeshNode.d.ts +36 -0
  41. package/dist/dragonbones/db-cocos/SimpleMeshNode.d.ts.map +1 -0
  42. package/dist/dragonbones/db-cocos/SimpleMeshNode.js +354 -0
  43. package/dist/dragonbones/index.d.ts +0 -1
  44. package/dist/dragonbones/index.d.ts.map +1 -1
  45. package/dist/dragonbones/index.js +0 -1
  46. package/dist/polyfills.d.ts +1 -1
  47. package/dist/polyfills.d.ts.map +1 -1
  48. package/dist/polyfills.js +1 -2
  49. package/dist/render/RenderComponent.d.ts.map +1 -1
  50. package/dist/render/RenderComponent.js +1 -0
  51. package/dist/render/RenderSystem.d.ts.map +1 -1
  52. package/dist/render/RenderSystem.js +34 -2
  53. package/dist/richtext/RichTextComp.js +1 -1
  54. package/dist/spine/SpineSkeleton.d.ts +5 -3
  55. package/dist/spine/SpineSkeleton.d.ts.map +1 -1
  56. package/dist/spine/SpineSkeleton.js +12 -5
  57. package/dist/spine/SpineSystem.d.ts +1 -2
  58. package/dist/spine/SpineSystem.d.ts.map +1 -1
  59. package/dist/spine/SpineSystem.js +22 -24
  60. package/dist/spine/index.d.ts +0 -1
  61. package/dist/spine/index.d.ts.map +1 -1
  62. package/dist/spine/index.js +14 -2
  63. package/dist/spine/spine-cocos/CCSkeleton.d.ts +86 -0
  64. package/dist/spine/spine-cocos/CCSkeleton.d.ts.map +1 -0
  65. package/dist/spine/spine-cocos/CCSkeleton.js +231 -0
  66. package/dist/spine/spine-cocos/CCSkeletonAnimation.d.ts +88 -0
  67. package/dist/spine/spine-cocos/CCSkeletonAnimation.d.ts.map +1 -0
  68. package/dist/spine/spine-cocos/CCSkeletonAnimation.js +251 -0
  69. package/dist/spine/spine-cocos/CCSkeletonCanvasRenderCmd.d.ts +28 -0
  70. package/dist/spine/spine-cocos/CCSkeletonCanvasRenderCmd.d.ts.map +1 -0
  71. package/dist/spine/spine-cocos/CCSkeletonCanvasRenderCmd.js +224 -0
  72. package/dist/spine/spine-cocos/CCSkeletonTexture.d.ts +36 -0
  73. package/dist/spine/spine-cocos/CCSkeletonTexture.d.ts.map +1 -0
  74. package/dist/spine/spine-cocos/CCSkeletonTexture.js +59 -0
  75. package/dist/spine/spine-cocos/CCSkeletonWebGLRenderCmd.d.ts +28 -0
  76. package/dist/spine/spine-cocos/CCSkeletonWebGLRenderCmd.d.ts.map +1 -0
  77. package/dist/spine/spine-cocos/CCSkeletonWebGLRenderCmd.js +277 -0
  78. package/package.json +6 -7
@@ -1,62 +1,69 @@
1
- import { EventObject } from 'dragonbones-pixijs';
2
1
  import { EventTypes } from 'entityx-ts';
2
+ import { EventObject } from '@cocos/dragonbones-js';
3
3
  import { NodeComp } from '../core/NodeComp';
4
4
  import { DragonBonesComp } from './DragonBonesComp';
5
- import { PixiDragonBonesSprite } from './PixiDragonBonesSprite';
5
+ import { CocosFactory } from './db-cocos/CocosFactory';
6
6
  export class DragonBonesSystem {
7
7
  configure(event_manager) {
8
- event_manager.subscribe(EventTypes.ComponentAdded, DragonBonesComp, async ({ entity }) => {
9
- const dbComp = entity.getComponent(DragonBonesComp);
8
+ CocosFactory.newInstance();
9
+ event_manager.subscribe(EventTypes.ComponentAdded, DragonBonesComp, async ({ entity, component: dbComp }) => {
10
10
  const { data, animation, playTimes = 0, timeScale = 1 } = dbComp.props;
11
+ // const texturePath = atlas.replace('.json', '.png')
11
12
  const { atlas, skeleton, texture } = data;
12
- const dragon = new PixiDragonBonesSprite({
13
- skeleton,
14
- atlas,
15
- texture,
16
- animationName: animation,
17
- playTimes,
18
- // width: dataSkel.armature[0].aabb.width,
19
- // height: dataSkel.armature[0].aabb.height,
20
- });
21
- dbComp.armature = dragon._armatureDisplay;
22
- dbComp.dragon = dragon;
23
- // console.log('armature', dbComp.armature)
24
- dbComp.armature.animation.timeScale = timeScale;
25
- const node = new cc.Node();
26
- node.addChild(dragon);
13
+ // cc.textureCache.addImage(texture)
14
+ const factory = CocosFactory.factory;
15
+ const dataSkel = cc.loader.getRes(skeleton);
16
+ const dataAtlas = cc.loader.getRes(atlas);
17
+ const textureCache = cc.textureCache.getTextureForKey(texture);
18
+ // texture.initWithFile(texturePath)
19
+ factory.parseDragonBonesData(dataSkel);
20
+ factory.parseTextureAtlasData(dataAtlas, textureCache);
21
+ // factory.loadDragonBonesData(skel)
22
+ // console.log(skeleton, dataSkel)
23
+ const node = factory.buildArmatureDisplay(dataSkel.armature[0].name, dataSkel.name);
24
+ // console.log('node', node)
25
+ // armature.animation.gotoAndPlay('run', 0.2)
26
+ node.armature.animation.timeScale = timeScale;
27
+ if (animation) {
28
+ const state = node.armature.animation.gotoAndPlayByTime(animation, 0, playTimes);
29
+ }
30
+ // console.log('state', state);
31
+ // if (skin) {
32
+ // node.setSkin(skin)
33
+ // }
27
34
  dbComp.node = entity.assign(new NodeComp(node, entity));
28
35
  if (dbComp.props.onAnimationStart)
29
- dbComp.armature.addDBEventListener(EventObject.START, () => {
36
+ node.armature.eventDispatcher.addDBEventListener(EventObject.START, (event) => {
30
37
  if (dbComp.node.active && dbComp.enabled)
31
38
  dbComp.props.onAnimationStart();
32
39
  }, dbComp);
33
40
  if (dbComp.props.onAnimationEnd)
34
- dbComp.armature.addDBEventListener(EventObject.COMPLETE, () => {
41
+ node.armature.eventDispatcher.addDBEventListener(EventObject.COMPLETE, (event) => {
35
42
  if (dbComp.node.active && dbComp.enabled)
36
43
  dbComp.props.onAnimationEnd();
37
44
  }, dbComp);
38
45
  if (dbComp.props.onAnimationComplete)
39
- dbComp.armature.addDBEventListener(EventObject.LOOP_COMPLETE, () => {
46
+ node.armature.eventDispatcher.addDBEventListener(EventObject.LOOP_COMPLETE, (event) => {
40
47
  if (dbComp.node.active && dbComp.enabled)
41
48
  dbComp.props.onAnimationComplete();
42
49
  }, dbComp);
43
50
  });
44
51
  event_manager.subscribe(EventTypes.ComponentRemoved, DragonBonesComp, ({ component }) => {
45
- const dbComp = component;
46
- // dbComp.armature.removeDBEventListener()
47
- dbComp.armature.destroy();
52
+ const armature = component.node.instance;
53
+ armature.destroy();
48
54
  // console.log('remove dragonbones component', dbComp.node.entity.id)
49
55
  });
50
56
  }
51
- // update(entities: EntityManager, events: EventManager, dt: number)
52
- update(entities) {
53
- const animations = entities.entities_with_components(DragonBonesComp);
54
- animations.forEach((ett) => {
55
- const dbComp = ett.getComponent(DragonBonesComp);
56
- if (dbComp.node && dbComp.node.active) {
57
- // console.log(' dragonbones updateTexture', dbComp.node.entity.id)
58
- dbComp.dragon.updateTexture();
59
- }
60
- });
57
+ update(entities, events, dt) {
58
+ // update(entities: EntityManager) {
59
+ // const animations = entities.entities_with_components(DragonBonesComp)
60
+ // animations.forEach((ett) => {
61
+ // const dbComp = ett.getComponent(DragonBonesComp)
62
+ // if (dbComp.node && dbComp.node.active) {
63
+ // // console.log(' dragonbones updateTexture', dbComp.node.entity.id)
64
+ // dbComp.dragon.updateTexture()
65
+ // }
66
+ // })
67
+ CocosFactory.advanceTime(dt);
61
68
  }
62
69
  }
@@ -0,0 +1,87 @@
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 { Animation, Armature, EventObject, EventStringType, IArmatureProxy } from '@cocos/dragonbones-js';
24
+ export type EventCallbackType = (...args: any[]) => void;
25
+ export interface EventMap {
26
+ [key: string]: [EventCallbackType];
27
+ }
28
+ export declare class CocosArmatureDisplay extends cc.Sprite implements IArmatureProxy {
29
+ /**
30
+ * @private
31
+ */
32
+ debugDraw: boolean;
33
+ private _debugDraw;
34
+ private _armature;
35
+ private _debugDrawer;
36
+ listenerCount: {};
37
+ events: EventMap;
38
+ constructor();
39
+ hasEvent(type: EventStringType): boolean;
40
+ addEvent(type: EventStringType, listener: Function, thisObject: any): void;
41
+ removeEvent(type: EventStringType, listener: Function, thisObject: any): void;
42
+ /**
43
+ * @inheritDoc
44
+ */
45
+ dbInit(armature: Armature): void;
46
+ /**
47
+ * @inheritDoc
48
+ */
49
+ dbClear(): void;
50
+ /**
51
+ * @inheritDoc
52
+ */
53
+ dbUpdate(): void;
54
+ /**
55
+ * @inheritDoc
56
+ */
57
+ dispose(disposeProxy?: boolean): void;
58
+ /**
59
+ * @inheritDoc
60
+ */
61
+ destroy(): void;
62
+ /**
63
+ * @private
64
+ */
65
+ dispatchDBEvent(type: EventStringType, eventObject: EventObject): void;
66
+ /**
67
+ * @inheritDoc
68
+ */
69
+ hasDBEventListener(type: EventStringType): boolean;
70
+ /**
71
+ * @inheritDoc
72
+ */
73
+ addDBEventListener(type: EventStringType, listener: (event: EventObject) => void, target: any): void;
74
+ /**
75
+ * @inheritDoc
76
+ */
77
+ removeDBEventListener(type: EventStringType, listener: (event: EventObject) => void, target: any): void;
78
+ /**
79
+ * @inheritDoc
80
+ */
81
+ get armature(): Armature;
82
+ /**
83
+ * @inheritDoc
84
+ */
85
+ get animation(): Animation;
86
+ }
87
+ //# sourceMappingURL=CocosArmatureDisplay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CocosArmatureDisplay.d.ts","sourceRoot":"","sources":["../../../src/dragonbones/db-cocos/CocosArmatureDisplay.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EACL,SAAS,EACT,QAAQ,EAGR,WAAW,EACX,eAAe,EACf,cAAc,EAEf,MAAM,uBAAuB,CAAA;AAE9B,MAAM,MAAM,iBAAiB,GAAG,CAAC,GAAG,IAAI,OAAA,KAAK,IAAI,CAAA;AACjD,MAAM,WAAW,QAAQ;IACvB,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,iBAAiB,CAAC,CAAA;CACnC;AACD,qBAAa,oBAAqB,SAAQ,EAAE,CAAC,MAAO,YAAW,cAAc;IAC3E;;OAEG;IACI,SAAS,UAAQ;IACxB,OAAO,CAAC,UAAU,CAAQ;IAE1B,OAAO,CAAC,SAAS,CAAwB;IACzC,OAAO,CAAC,YAAY,CAAyB;IAE7C,aAAa,KAAK;IAClB,MAAM,EAAE,QAAQ,CAAK;;IASrB,QAAQ,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO;IAIxC,QAAQ,CAAC,IAAI,EAAE,eAAe,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,GAAG,IAAI;IAI1E,WAAW,CAAC,IAAI,EAAE,eAAe,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,GAAG,IAAI;IAG7E;;OAEG;IACI,MAAM,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAGvC;;OAEG;IACI,OAAO,IAAI,IAAI;IAUtB;;OAEG;IACI,QAAQ,IAAI,IAAI;IAyHvB;;OAEG;IACI,OAAO,CAAC,YAAY,UAAO,GAAG,IAAI;IAOzC;;OAEG;IACI,OAAO,IAAI,IAAI;IAGtB;;OAEG;IACI,eAAe,CAAC,IAAI,EAAE,eAAe,EAAE,WAAW,EAAE,WAAW,GAAG,IAAI;IAS7E;;OAEG;IACI,kBAAkB,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO;IAKzD;;OAEG;IACI,kBAAkB,CAAC,IAAI,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,EAAE,MAAM,EAAE,GAAG,GAAG,IAAI;IAW3G;;OAEG;IACI,qBAAqB,CAAC,IAAI,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,EAAE,MAAM,EAAE,GAAG,GAAG,IAAI;IAK9G;;OAEG;IACH,IAAW,QAAQ,IAAI,QAAQ,CAE9B;IACD;;OAEG;IACH,IAAW,SAAS,IAAI,SAAS,CAEhC;CACF"}
@@ -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,127 @@
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 Cocos factory.
28
+ * @version DragonBones 3.0
29
+ * @language en_US
30
+ */
31
+ /**
32
+ * - Cocos 工厂。
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
+ /**
42
+ * - A global factory instance that can be used directly.
43
+ * @version DragonBones 4.7
44
+ * @language en_US
45
+ */
46
+ /**
47
+ * - 一个可以直接使用的全局工厂实例。
48
+ * @version DragonBones 4.7
49
+ * @language zh_CN
50
+ */
51
+ static get factory(): CocosFactory;
52
+ /**
53
+ * - 一个获取全局工厂实例(单例)的方法, 和get factory相比, 优点是可以传参数。
54
+ * @version DragonBones 4.7
55
+ * @language zh_CN
56
+ */
57
+ static newInstance(): CocosFactory;
58
+ /**
59
+ * @inheritDoc
60
+ */
61
+ constructor(dataParser?: DataParser | null);
62
+ protected _buildTextureAtlasData(textureAtlasData: CocosTextureAtlasData | null, textureAtlas: cc.Texture2D | null): CocosTextureAtlasData;
63
+ protected _buildArmature(dataPackage: BuildArmaturePackage): Armature;
64
+ protected _buildSlot(_dataPackage: BuildArmaturePackage, slotData: SlotData, armature: DisplayData[]): Slot;
65
+ /**
66
+ * - Create a armature from cached DragonBonesData instances and TextureAtlasData instances, then use the {@link #clock} to update it.
67
+ * The difference is that the armature created by {@link #buildArmature} is not WorldClock instance update.
68
+ * @param armatureName - The armature data name.
69
+ * @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)
70
+ * @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)
71
+ * @returns The armature display container.
72
+ * @see dragonBones.IArmatureProxy
73
+ * @see dragonBones.BaseFactory#buildArmature
74
+ * @version DragonBones 4.5
75
+ * @example
76
+ * <pre>
77
+ * let armatureDisplay = factory.buildArmatureDisplay("armatureName", "dragonBonesName");
78
+ * </pre>
79
+ * @language en_US
80
+ */
81
+ /**
82
+ * - 通过缓存的 DragonBonesData 实例和 TextureAtlasData 实例创建一个骨架,并用 {@link #clock} 更新该骨架。
83
+ * 区别在于由 {@link #buildArmature} 创建的骨架没有 WorldClock 实例驱动。
84
+ * @param armatureName - 骨架数据名称。
85
+ * @param dragonBonesName - DragonBonesData 实例的缓存名称。 (如果未设置,将检索所有的 DragonBonesData 实例,当多个 DragonBonesData 实例中包含同名的骨架数据时,可能无法准确的创建出特定的骨架)
86
+ * @param skinName - 皮肤名称,可以设置一个其他骨架数据名称来共享其皮肤数据。 (如果未设置,则使用默认的皮肤数据)
87
+ * @returns 骨架的显示容器。
88
+ * @see dragonBones.IArmatureProxy
89
+ * @see dragonBones.BaseFactory#buildArmature
90
+ * @version DragonBones 4.5
91
+ * @example
92
+ * <pre>
93
+ * let armatureDisplay = factory.buildArmatureDisplay("armatureName", "dragonBonesName");
94
+ * </pre>
95
+ * @language zh_CN
96
+ */
97
+ buildArmatureDisplay(armatureName: string, dragonBonesName?: string, skinName?: string, textureAtlasName?: string): CocosArmatureDisplay | null;
98
+ /**
99
+ * - Create the display object with the specified texture.
100
+ * @param textureName - The texture data name.
101
+ * @param textureAtlasName - The texture atlas data name (Of not set, all texture atlas data will be searched)
102
+ * @version DragonBones 3.0
103
+ * @language en_US
104
+ */
105
+ /**
106
+ * - 创建带有指定贴图的显示对象。
107
+ * @param textureName - 贴图数据名称。
108
+ * @param textureAtlasName - 贴图集数据名称。 (如果未设置,将检索所有的贴图集数据)
109
+ * @version DragonBones 3.0
110
+ * @language zh_CN
111
+ */
112
+ getTextureDisplay(textureName: string, textureAtlasName?: string | null): cc.Sprite | null;
113
+ /**
114
+ * - A global sound event manager.
115
+ * Sound events can be listened to uniformly from the manager.
116
+ * @version DragonBones 4.5
117
+ * @language en_US
118
+ */
119
+ /**
120
+ * - 全局声音事件管理器。
121
+ * 声音事件可以从该管理器统一侦听。
122
+ * @version DragonBones 4.5
123
+ * @language zh_CN
124
+ */
125
+ get soundEventManager(): CocosArmatureDisplay;
126
+ }
127
+ //# 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;IAInD;;;;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"}