@safe-engine/cocos 1.0.1

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 (112) hide show
  1. package/@types/index.d.ts +61 -0
  2. package/@types/safex.d.ts +103 -0
  3. package/README.md +10 -0
  4. package/dist/app.d.ts +2 -0
  5. package/dist/app.d.ts.map +1 -0
  6. package/dist/app.js +24 -0
  7. package/dist/dragonbones/cocos/CocosArmatureDisplay.d.ts +77 -0
  8. package/dist/dragonbones/cocos/CocosArmatureDisplay.d.ts.map +1 -0
  9. package/dist/dragonbones/cocos/CocosArmatureDisplay.js +227 -0
  10. package/dist/dragonbones/cocos/CocosFactory.d.ts +128 -0
  11. package/dist/dragonbones/cocos/CocosFactory.d.ts.map +1 -0
  12. package/dist/dragonbones/cocos/CocosFactory.js +231 -0
  13. package/dist/dragonbones/cocos/CocosSlot.d.ts +49 -0
  14. package/dist/dragonbones/cocos/CocosSlot.d.ts.map +1 -0
  15. package/dist/dragonbones/cocos/CocosSlot.js +385 -0
  16. package/dist/dragonbones/cocos/CocosTextureAtlasData.d.ts +53 -0
  17. package/dist/dragonbones/cocos/CocosTextureAtlasData.d.ts.map +1 -0
  18. package/dist/dragonbones/cocos/CocosTextureAtlasData.js +158 -0
  19. package/dist/dragonbones/dragonBones.d.ts +3 -0
  20. package/dist/dragonbones/dragonBones.d.ts.map +1 -0
  21. package/dist/dragonbones/dragonBones.js +4788 -0
  22. package/dist/dragonbones/index.d.ts +20 -0
  23. package/dist/dragonbones/index.d.ts.map +1 -0
  24. package/dist/dragonbones/index.js +112 -0
  25. package/dist/gworld/components/AnimationComponent.d.ts +65 -0
  26. package/dist/gworld/components/AnimationComponent.d.ts.map +1 -0
  27. package/dist/gworld/components/AnimationComponent.js +141 -0
  28. package/dist/gworld/components/CollideComponent.d.ts +64 -0
  29. package/dist/gworld/components/CollideComponent.d.ts.map +1 -0
  30. package/dist/gworld/components/CollideComponent.js +266 -0
  31. package/dist/gworld/components/EnhancedComponent.d.ts +21 -0
  32. package/dist/gworld/components/EnhancedComponent.d.ts.map +1 -0
  33. package/dist/gworld/components/EnhancedComponent.js +50 -0
  34. package/dist/gworld/components/GUIComponent.d.ts +62 -0
  35. package/dist/gworld/components/GUIComponent.d.ts.map +1 -0
  36. package/dist/gworld/components/GUIComponent.js +158 -0
  37. package/dist/gworld/components/NoRenderComponent.d.ts +36 -0
  38. package/dist/gworld/components/NoRenderComponent.d.ts.map +1 -0
  39. package/dist/gworld/components/NoRenderComponent.js +74 -0
  40. package/dist/gworld/components/NodeComp.d.ts +184 -0
  41. package/dist/gworld/components/NodeComp.d.ts.map +1 -0
  42. package/dist/gworld/components/NodeComp.js +425 -0
  43. package/dist/gworld/components/RenderComponent.d.ts +53 -0
  44. package/dist/gworld/components/RenderComponent.d.ts.map +1 -0
  45. package/dist/gworld/components/RenderComponent.js +158 -0
  46. package/dist/gworld/core/Scene.d.ts +5 -0
  47. package/dist/gworld/core/Scene.d.ts.map +1 -0
  48. package/dist/gworld/core/Scene.js +38 -0
  49. package/dist/gworld/core/decorator.d.ts +9 -0
  50. package/dist/gworld/core/decorator.d.ts.map +1 -0
  51. package/dist/gworld/core/decorator.js +43 -0
  52. package/dist/gworld/index.d.ts +8 -0
  53. package/dist/gworld/index.d.ts.map +1 -0
  54. package/dist/gworld/index.js +43 -0
  55. package/dist/gworld/systems/AnimationSystem.d.ts +7 -0
  56. package/dist/gworld/systems/AnimationSystem.d.ts.map +1 -0
  57. package/dist/gworld/systems/AnimationSystem.js +38 -0
  58. package/dist/gworld/systems/CollideSystem.d.ts +19 -0
  59. package/dist/gworld/systems/CollideSystem.d.ts.map +1 -0
  60. package/dist/gworld/systems/CollideSystem.js +183 -0
  61. package/dist/gworld/systems/GUISystem.d.ts +7 -0
  62. package/dist/gworld/systems/GUISystem.d.ts.map +1 -0
  63. package/dist/gworld/systems/GUISystem.js +147 -0
  64. package/dist/gworld/systems/NoRenderSystem.d.ts +7 -0
  65. package/dist/gworld/systems/NoRenderSystem.d.ts.map +1 -0
  66. package/dist/gworld/systems/NoRenderSystem.js +93 -0
  67. package/dist/gworld/systems/RenderSystem.d.ts +15 -0
  68. package/dist/gworld/systems/RenderSystem.d.ts.map +1 -0
  69. package/dist/gworld/systems/RenderSystem.js +115 -0
  70. package/dist/helper/Intersection.d.ts +6 -0
  71. package/dist/helper/Intersection.d.ts.map +1 -0
  72. package/dist/helper/Intersection.js +117 -0
  73. package/dist/helper/NodePool.d.ts +9 -0
  74. package/dist/helper/NodePool.d.ts.map +1 -0
  75. package/dist/helper/NodePool.js +29 -0
  76. package/dist/helper/action.d.ts +9 -0
  77. package/dist/helper/action.d.ts.map +1 -0
  78. package/dist/helper/action.js +34 -0
  79. package/dist/helper/director.d.ts +3 -0
  80. package/dist/helper/director.d.ts.map +1 -0
  81. package/dist/helper/director.js +10 -0
  82. package/dist/helper/html-text-parser.d.ts +30 -0
  83. package/dist/helper/html-text-parser.d.ts.map +1 -0
  84. package/dist/helper/html-text-parser.js +354 -0
  85. package/dist/helper/math.d.ts +4 -0
  86. package/dist/helper/math.d.ts.map +1 -0
  87. package/dist/helper/math.js +9 -0
  88. package/dist/helper/utils.d.ts +14 -0
  89. package/dist/helper/utils.d.ts.map +1 -0
  90. package/dist/helper/utils.js +81 -0
  91. package/dist/index.d.ts +19 -0
  92. package/dist/index.d.ts.map +1 -0
  93. package/dist/index.js +33 -0
  94. package/dist/polyfills.d.ts +54 -0
  95. package/dist/polyfills.d.ts.map +1 -0
  96. package/dist/polyfills.js +168 -0
  97. package/dist/spine/CCSkeleton.d.ts +2 -0
  98. package/dist/spine/CCSkeleton.d.ts.map +1 -0
  99. package/dist/spine/CCSkeleton.js +380 -0
  100. package/dist/spine/CCSkeletonAnimation.d.ts +16 -0
  101. package/dist/spine/CCSkeletonAnimation.d.ts.map +1 -0
  102. package/dist/spine/CCSkeletonAnimation.js +353 -0
  103. package/dist/spine/CCSkeletonCanvasRenderCmd.d.ts +2 -0
  104. package/dist/spine/CCSkeletonCanvasRenderCmd.d.ts.map +1 -0
  105. package/dist/spine/CCSkeletonCanvasRenderCmd.js +229 -0
  106. package/dist/spine/CCSkeletonTexture.d.ts +2 -0
  107. package/dist/spine/CCSkeletonTexture.d.ts.map +1 -0
  108. package/dist/spine/CCSkeletonTexture.js +98 -0
  109. package/dist/spine/CCSkeletonWebGLRenderCmd.d.ts +2 -0
  110. package/dist/spine/CCSkeletonWebGLRenderCmd.d.ts.map +1 -0
  111. package/dist/spine/CCSkeletonWebGLRenderCmd.js +317 -0
  112. package/package.json +32 -0
@@ -0,0 +1,61 @@
1
+ type Float = number
2
+ type Integer = number
3
+
4
+ declare namespace cc {
5
+ declare let v2: (x?: number | any, y?: number) => Vec2
6
+ declare let v3: (x?: number | any, y?: number, z?: number) => Vec3
7
+ declare let instantiate: (id: string) => NodeComp
8
+
9
+ declare interface Misc {
10
+ radiansToDegrees(angle: number): number
11
+ degreesToRadians: (angle: number) => number
12
+ clampf: (value: number, min_inclusive: number, max_inclusive: number) => number
13
+ lerp: (a: number, b: number, r: number) => number
14
+ }
15
+ declare interface Macro {
16
+ REPEAT_FOREVER: number
17
+ }
18
+ declare interface TextureCache {
19
+ addImage(texturePath: string): Texture2D
20
+ getTextureForKey(key: string): Texture2D
21
+ }
22
+
23
+ declare let misc: Misc
24
+ declare let macro: Macro
25
+ // declare let Vec2: any;
26
+ declare let RigidBodyType: any
27
+ declare let textureCache: TextureCache
28
+
29
+ declare namespace Event {
30
+ interface EventTouch {
31
+ getLocation(): cc.Vec2
32
+ getLocationX(): number
33
+ getLocationY(): number
34
+ getDelta(): cc.Vec2
35
+ getDeltaX(): number
36
+ getDeltaY(): number
37
+ }
38
+ }
39
+ // declare function Vec2(x?: number, y?: number): Vec2;
40
+ declare class Vec2 extends Point {
41
+ x: number
42
+ y: number
43
+ static ZERO: Vec2
44
+ constructor(x?: number, y?: number)
45
+ equals(lastPos: Vec2): boolean
46
+ add(value: cc.Point): cc.Vec2
47
+ addSelf(value: cc.Point): cc.Vec2
48
+ sub(value: cc.Point): cc.Vec2
49
+ mul(multiply: number): cc.Vec2
50
+ mulSelf(multiply: number): cc.Vec2
51
+ mag(): number
52
+ normalizeSelf(): cc.Vec2
53
+ normalize(): cc.Vec2
54
+ public signAngle(other: Vec2)
55
+ }
56
+
57
+ export class Vec3 extends Vec2 {}
58
+ export class ParticleSystem extends Node {
59
+ constructor(file: string)
60
+ }
61
+ }
@@ -0,0 +1,103 @@
1
+ import { Color4B, NodeComp } from '../src'
2
+
3
+ type ColorSource = ReturnType<typeof Color4B>
4
+
5
+ interface BaseComponentProps {
6
+ $ref?: unknown
7
+ $refNode?: NodeComp<any>
8
+ $push?: unknown[]
9
+ node?: Partial<NodeComp>
10
+ // [$key: `$${string}`]: string
11
+ }
12
+
13
+ interface NodeCompProps {
14
+ nodeName?: string
15
+ }
16
+
17
+ interface GraphicsRenderProps {
18
+ lineWidth?: number
19
+ strokeColor?: ColorSource
20
+ fillColor?: ColorSource
21
+ }
22
+
23
+ interface ProgressTimerProps {
24
+ spriteFrame: string
25
+ fillType?: LoadingBarMode
26
+ fillRange?: number
27
+ fillCenter?: Point
28
+ isReverse?: boolean
29
+ }
30
+
31
+ // interface LoadingBarProps {}
32
+
33
+ interface LabelCompProps {
34
+ font?: string
35
+ string?: string
36
+ size?: number
37
+ }
38
+
39
+ interface ScrollViewProps {
40
+ width: number
41
+ height: number
42
+ }
43
+
44
+ interface LabelOutlineCompProps {
45
+ color: ColorSource
46
+ width: number
47
+ }
48
+
49
+ interface LabelShadowCompProps {
50
+ color: ColorSource
51
+ blur: number
52
+ offset: Point
53
+ }
54
+
55
+ interface SpineData {
56
+ atlas: string
57
+ skeleton: string
58
+ texture?: string
59
+ }
60
+
61
+ interface DragonBonesData {
62
+ atlas: string
63
+ skeleton: string
64
+ texture: string
65
+ }
66
+ interface DragonBonesProps {
67
+ data: DragonBonesData
68
+ skin?: string
69
+ animation?: string
70
+ playTimes?: number
71
+ timeScale?: number
72
+ onAnimationStart?: (event: { name: string }) => void
73
+ onAnimationEnd?: (event: { name: string }) => void
74
+ onAnimationComplete?: (event: { name: string }) => void
75
+ }
76
+
77
+ interface PhysicsMaterialProps {
78
+ friction?: number
79
+ restitution?: number
80
+ density?: number
81
+ }
82
+
83
+ interface ColliderPhysicsProps {
84
+ tag?: number
85
+ group?: number
86
+ offset?: Vec2
87
+ onCollisionEnter?: (other: Collider) => void
88
+ onCollisionExit?: (other: Collider) => void
89
+ onCollisionStay?: (other: Collider) => void
90
+ }
91
+
92
+ interface BoxColliderPhysicsProps {
93
+ width: number
94
+ height: number
95
+ }
96
+
97
+ interface CircleColliderPhysicsProps {
98
+ radius: number
99
+ }
100
+
101
+ interface PolygonColliderPhysicsProps {
102
+ points: Array<Vec2>
103
+ }
package/README.md ADDED
@@ -0,0 +1,10 @@
1
+ # Guide
2
+ - all components must be extends from `ComponentX` or `NoRenderComponentX`
3
+ - `NoRenderComponentX` will append to component of parent node have `ComponentX`, `ComponentX` will be `addChild` to parent node
4
+ - `node` property represent node, and can pass properties to assign
5
+ - example ```<SpriteRender node={{ x: 5, y: 9 }} />```
6
+ - `$ref` bind component with current class property as string
7
+ - `$push` push component to list
8
+ - `Array(2).map(_, i)` iteration repeat component 2 times
9
+ - `Loading.listItems.map(item, i)` iteration in static property
10
+ - `listItems.map(item, i)` iteration in const variable
package/dist/app.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export declare function initWorld(): void;
2
+ //# sourceMappingURL=app.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAOA,wBAAgB,SAAS,SAcxB"}
package/dist/app.js ADDED
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.initWorld = initWorld;
4
+ var dragonbones_1 = require("./dragonbones");
5
+ var gworld_1 = require("./gworld");
6
+ var CollideSystem_1 = require("./gworld/systems/CollideSystem");
7
+ var GUISystem_1 = require("./gworld/systems/GUISystem");
8
+ var NoRenderSystem_1 = require("./gworld/systems/NoRenderSystem");
9
+ var RenderSystem_1 = require("./gworld/systems/RenderSystem");
10
+ function initWorld() {
11
+ gworld_1.GameWorld.Instance.systems.add(RenderSystem_1.RenderSystem);
12
+ // GameWorld.Instance.systems.add(PhysicsSystem)
13
+ gworld_1.GameWorld.Instance.systems.add(CollideSystem_1.CollideSystem);
14
+ gworld_1.GameWorld.Instance.systems.add(GUISystem_1.GUISystem);
15
+ gworld_1.GameWorld.Instance.systems.add(NoRenderSystem_1.NoRenderSystem);
16
+ // GameWorld.Instance.listUpdate.push(PhysicsSystem)
17
+ gworld_1.GameWorld.Instance.listUpdate.push(CollideSystem_1.CollideSystem);
18
+ gworld_1.GameWorld.Instance.systems.configureOnce(RenderSystem_1.RenderSystem);
19
+ // GameWorld.Instance.systems.configureOnce(PhysicsSystem)
20
+ gworld_1.GameWorld.Instance.systems.configureOnce(CollideSystem_1.CollideSystem);
21
+ gworld_1.GameWorld.Instance.systems.configureOnce(GUISystem_1.GUISystem);
22
+ gworld_1.GameWorld.Instance.systems.configureOnce(NoRenderSystem_1.NoRenderSystem);
23
+ (0, dragonbones_1.setupDragonBones)();
24
+ }
@@ -0,0 +1,77 @@
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, EventObject, EventStringType, IArmatureProxy } from '@cocos/dragonbones-js';
24
+ export declare class CocosArmatureDisplay extends cc.Sprite implements IArmatureProxy {
25
+ /**
26
+ * @private
27
+ */
28
+ debugDraw: boolean;
29
+ private _debugDraw;
30
+ private _armature;
31
+ private _debugDrawer;
32
+ /**
33
+ * @inheritDoc
34
+ */
35
+ dbInit(armature: Armature): void;
36
+ /**
37
+ * @inheritDoc
38
+ */
39
+ dbClear(): void;
40
+ /**
41
+ * @inheritDoc
42
+ */
43
+ dbUpdate(): void;
44
+ /**
45
+ * @inheritDoc
46
+ */
47
+ dispose(disposeProxy?: boolean): void;
48
+ /**
49
+ * @inheritDoc
50
+ */
51
+ destroy(): void;
52
+ /**
53
+ * @private
54
+ */
55
+ dispatchDBEvent(type: EventStringType, eventObject: EventObject): void;
56
+ /**
57
+ * @inheritDoc
58
+ */
59
+ hasDBEventListener(type: EventStringType): boolean;
60
+ /**
61
+ * @inheritDoc
62
+ */
63
+ addDBEventListener(type: EventStringType, listener: (event: EventObject) => void, target: any): void;
64
+ /**
65
+ * @inheritDoc
66
+ */
67
+ removeDBEventListener(type: EventStringType, listener: (event: EventObject) => void, target: any): void;
68
+ /**
69
+ * @inheritDoc
70
+ */
71
+ get armature(): Armature;
72
+ /**
73
+ * @inheritDoc
74
+ */
75
+ get animation(): Animation;
76
+ }
77
+ //# sourceMappingURL=CocosArmatureDisplay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":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**
4
+ * The MIT License (MIT)
5
+ *
6
+ * Copyright (c) 2012-2018 DragonBones team and other contributors
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
9
+ * this software and associated documentation files (the "Software"), to deal in
10
+ * the Software without restriction, including without limitation the rights to
11
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
12
+ * the Software, and to permit persons to whom the Software is furnished to do so,
13
+ * subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in all
16
+ * copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
20
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
21
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
22
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
+ */
25
+ var __extends = (this && this.__extends) || (function () {
26
+ var extendStatics = function (d, b) {
27
+ extendStatics = Object.setPrototypeOf ||
28
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
29
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
30
+ return extendStatics(d, b);
31
+ };
32
+ return function (d, b) {
33
+ if (typeof b !== "function" && b !== null)
34
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
35
+ extendStatics(d, b);
36
+ function __() { this.constructor = d; }
37
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
38
+ };
39
+ })();
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ exports.CocosArmatureDisplay = void 0;
42
+ var dragonbones_js_1 = require("@cocos/dragonbones-js");
43
+ var CocosArmatureDisplay = /** @class */ (function (_super) {
44
+ __extends(CocosArmatureDisplay, _super);
45
+ function CocosArmatureDisplay() {
46
+ var _this = _super !== null && _super.apply(this, arguments) || this;
47
+ /**
48
+ * @private
49
+ */
50
+ _this.debugDraw = false;
51
+ _this._debugDraw = false;
52
+ // private _disposeProxy: boolean = false;
53
+ _this._armature = null;
54
+ _this._debugDrawer = null;
55
+ return _this;
56
+ }
57
+ /**
58
+ * @inheritDoc
59
+ */
60
+ CocosArmatureDisplay.prototype.dbInit = function (armature) {
61
+ this._armature = armature;
62
+ };
63
+ /**
64
+ * @inheritDoc
65
+ */
66
+ CocosArmatureDisplay.prototype.dbClear = function () {
67
+ if (this._debugDrawer !== null) {
68
+ this._debugDrawer.removeFromParent();
69
+ }
70
+ this._armature = null;
71
+ this._debugDrawer = null;
72
+ _super.prototype.removeFromParent.call(this);
73
+ };
74
+ /**
75
+ * @inheritDoc
76
+ */
77
+ CocosArmatureDisplay.prototype.dbUpdate = function () {
78
+ var drawed = dragonbones_js_1.DragonBones.debugDraw || this.debugDraw;
79
+ if (drawed || this._debugDraw) {
80
+ this._debugDraw = drawed;
81
+ if (this._debugDraw) {
82
+ if (this._debugDrawer === null) {
83
+ this._debugDrawer = new cc.Sprite();
84
+ var boneDrawer_1 = new cc.DrawNode();
85
+ this._debugDrawer.addChild(boneDrawer_1);
86
+ }
87
+ this.addChild(this._debugDrawer);
88
+ var boneDrawer = this._debugDrawer.children[0];
89
+ boneDrawer.clear();
90
+ var bones = this._armature.getBones();
91
+ for (var i = 0, l = bones.length; i < l; ++i) {
92
+ var bone = bones[i];
93
+ var boneLength = bone.boneData.length;
94
+ var startX = bone.globalTransformMatrix.tx;
95
+ var startY = bone.globalTransformMatrix.ty;
96
+ var endX = startX + bone.globalTransformMatrix.a * boneLength;
97
+ var endY = startY + bone.globalTransformMatrix.b * boneLength;
98
+ boneDrawer.setLineWidth(2.0);
99
+ boneDrawer.setColor(cc.color('0x00FFFF'));
100
+ boneDrawer.drawSegment(cc.p(startX, startY), cc.p(endX, endY));
101
+ // boneDrawer.lineStyle(0.0, 0, 0.0);
102
+ // boneDrawer.beginFill(0x00FFFF, 0.7);
103
+ boneDrawer.drawCircle(cc.p(startX, startY), 3.0, Math.PI * 2, 64);
104
+ // boneDrawer.endFill();
105
+ }
106
+ var slots = this._armature.getSlots();
107
+ for (var i = 0, l = slots.length; i < l; ++i) {
108
+ var slot = slots[i];
109
+ var boundingBoxData = slot.boundingBoxData;
110
+ if (boundingBoxData) {
111
+ var child = this._debugDrawer.getChildByName(slot.name);
112
+ if (!child) {
113
+ child = new cc.DrawNode();
114
+ child.name = slot.name;
115
+ this._debugDrawer.addChild(child);
116
+ }
117
+ child.clear();
118
+ child.lineStyle(2.0, 0xFF00FF, 0.7);
119
+ switch (boundingBoxData.type) {
120
+ case dragonbones_js_1.BoundingBoxType.Rectangle:
121
+ child.drawRect(-boundingBoxData.width * 0.5, -boundingBoxData.height * 0.5, boundingBoxData.width, boundingBoxData.height);
122
+ break;
123
+ case dragonbones_js_1.BoundingBoxType.Ellipse:
124
+ child.drawEllipse(-boundingBoxData.width * 0.5, -boundingBoxData.height * 0.5, boundingBoxData.width, boundingBoxData.height);
125
+ break;
126
+ case dragonbones_js_1.BoundingBoxType.Polygon:
127
+ var vertices = boundingBoxData.vertices;
128
+ for (var i_1 = 0, l_1 = vertices.length; i_1 < l_1; i_1 += 2) {
129
+ var x = vertices[i_1];
130
+ var y = vertices[i_1 + 1];
131
+ if (i_1 === 0) {
132
+ child.moveTo(x, y);
133
+ }
134
+ else {
135
+ child.lineTo(x, y);
136
+ }
137
+ }
138
+ child.lineTo(vertices[0], vertices[1]);
139
+ break;
140
+ default:
141
+ break;
142
+ }
143
+ child.endFill();
144
+ slot.updateTransformAndMatrix();
145
+ slot.updateGlobalTransform();
146
+ var transform = slot.global;
147
+ child.setTransform(transform.x, transform.y, transform.scaleX, transform.scaleY, transform.rotation, transform.skew, 0.0, slot._pivotX, slot._pivotY);
148
+ }
149
+ else {
150
+ var child = this._debugDrawer.getChildByName(slot.name);
151
+ if (child) {
152
+ this._debugDrawer.removeChild(child);
153
+ }
154
+ }
155
+ }
156
+ }
157
+ else if (this._debugDrawer !== null && this._debugDrawer.parent === this) {
158
+ this.removeChild(this._debugDrawer);
159
+ }
160
+ }
161
+ };
162
+ /**
163
+ * @inheritDoc
164
+ */
165
+ CocosArmatureDisplay.prototype.dispose = function (disposeProxy) {
166
+ if (disposeProxy === void 0) { disposeProxy = true; }
167
+ // tslint:disable-next-line:no-unused-expression
168
+ disposeProxy;
169
+ if (this._armature !== null) {
170
+ this._armature.dispose();
171
+ this._armature = null;
172
+ }
173
+ };
174
+ /**
175
+ * @inheritDoc
176
+ */
177
+ CocosArmatureDisplay.prototype.destroy = function () {
178
+ this.dispose();
179
+ };
180
+ /**
181
+ * @private
182
+ */
183
+ CocosArmatureDisplay.prototype.dispatchDBEvent = function (type, eventObject) {
184
+ this.emit(type, eventObject);
185
+ };
186
+ /**
187
+ * @inheritDoc
188
+ */
189
+ CocosArmatureDisplay.prototype.hasDBEventListener = function (type) {
190
+ // return this.listenerCount(type) > 0;
191
+ return false;
192
+ };
193
+ /**
194
+ * @inheritDoc
195
+ */
196
+ CocosArmatureDisplay.prototype.addDBEventListener = function (type, listener, target) {
197
+ this.addListener(type, listener, target);
198
+ };
199
+ /**
200
+ * @inheritDoc
201
+ */
202
+ CocosArmatureDisplay.prototype.removeDBEventListener = function (type, listener, target) {
203
+ this.removeListener(type, listener, target);
204
+ };
205
+ Object.defineProperty(CocosArmatureDisplay.prototype, "armature", {
206
+ /**
207
+ * @inheritDoc
208
+ */
209
+ get: function () {
210
+ return this._armature;
211
+ },
212
+ enumerable: false,
213
+ configurable: true
214
+ });
215
+ Object.defineProperty(CocosArmatureDisplay.prototype, "animation", {
216
+ /**
217
+ * @inheritDoc
218
+ */
219
+ get: function () {
220
+ return this._armature.animation;
221
+ },
222
+ enumerable: false,
223
+ configurable: true
224
+ });
225
+ return CocosArmatureDisplay;
226
+ }(cc.Sprite));
227
+ exports.CocosArmatureDisplay = CocosArmatureDisplay;
@@ -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, 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(useSharedTicker?: boolean): CocosFactory;
59
+ /**
60
+ * @inheritDoc
61
+ */
62
+ constructor(dataParser?: DataParser | null, useSharedTicker?: boolean);
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: Armature): 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.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