@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,168 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.Touch = exports.BLUE = exports.GREEN = exports.WHITE = exports.BLACK = exports.RED = exports.SpriteType = void 0;
19
+ exports.Vec2 = Vec2;
20
+ exports.Color4B = Color4B;
21
+ exports.Size = Size;
22
+ exports.getWinSize = getWinSize;
23
+ var Intersection_1 = require("./helper/Intersection");
24
+ function updatePoint(p) {
25
+ var x = p.x, y = p.y;
26
+ return cc.v2(x, y);
27
+ }
28
+ var _Vec2 = /** @class */ (function () {
29
+ function _Vec2(x, y) {
30
+ if (x === void 0) { x = 0; }
31
+ if (y === void 0) { y = 0; }
32
+ if (!(this instanceof _Vec2)) {
33
+ return new _Vec2(x, y);
34
+ }
35
+ if (typeof x === 'object') {
36
+ this.x = x.x;
37
+ this.y = x.y;
38
+ return;
39
+ }
40
+ this.x = x;
41
+ this.y = y;
42
+ }
43
+ _Vec2.prototype.equals = function (other) {
44
+ return this.x === other.x && this.y === other.y;
45
+ };
46
+ _Vec2.prototype.add = function (value) {
47
+ return updatePoint(cc.pAdd(cc.p(this.x, this.y), value));
48
+ };
49
+ _Vec2.prototype.addSelf = function (value) {
50
+ var nor = updatePoint(cc.pAdd(cc.p(this.x, this.y), value));
51
+ this.x = nor.x;
52
+ this.y = nor.y;
53
+ return nor;
54
+ };
55
+ _Vec2.prototype.sub = function (value) {
56
+ return updatePoint(cc.pSub(cc.p(this.x, this.y), value));
57
+ };
58
+ _Vec2.prototype.mul = function (multiply) {
59
+ return updatePoint(cc.pMult(cc.p(this.x, this.y), multiply));
60
+ };
61
+ _Vec2.prototype.mulSelf = function (multiply) {
62
+ var nor = updatePoint(cc.pMult(cc.p(this.x, this.y), multiply));
63
+ this.x = nor.x;
64
+ this.y = nor.y;
65
+ return nor;
66
+ };
67
+ _Vec2.prototype.mag = function () {
68
+ return cc.pLength(cc.p(this.x, this.y));
69
+ };
70
+ _Vec2.prototype.normalizeSelf = function () {
71
+ var nor = updatePoint(cc.pNormalize(cc.p(this.x, this.y)));
72
+ this.x = nor.x;
73
+ this.y = nor.y;
74
+ return nor;
75
+ };
76
+ _Vec2.prototype.normalize = function () {
77
+ return updatePoint(cc.pNormalize(cc.p(this.x, this.y)));
78
+ };
79
+ _Vec2.prototype.cross = function (other) {
80
+ return this.x * other.y - this.y * other.x;
81
+ };
82
+ _Vec2.prototype.signAngle = function (other) {
83
+ var angle = this.angle(other);
84
+ return this.cross(other) < 0 ? -angle : angle;
85
+ };
86
+ _Vec2.prototype.lengthSqr = function () {
87
+ return this.x * this.x + this.y * this.y;
88
+ };
89
+ _Vec2.prototype.dot = function (other) {
90
+ return this.x * other.x + this.y * other.y;
91
+ };
92
+ _Vec2.prototype.angle = function (other) {
93
+ var magSqr1 = this.lengthSqr();
94
+ var magSqr2 = other.lengthSqr();
95
+ if (magSqr1 === 0 || magSqr2 === 0) {
96
+ console.warn('Cant get angle between zero vector');
97
+ return 0.0;
98
+ }
99
+ var dot = this.dot(other);
100
+ var theta = dot / Math.sqrt(magSqr1 * magSqr2);
101
+ theta = cc.clampf(theta, -1.0, 1.0);
102
+ return Math.acos(theta);
103
+ };
104
+ _Vec2.prototype.distance = function (other) {
105
+ return cc.pDistance(this, other);
106
+ };
107
+ return _Vec2;
108
+ }());
109
+ function Vec2(x, y) {
110
+ return new _Vec2(x, y);
111
+ }
112
+ cc.Vec2 = _Vec2;
113
+ Vec2.ZERO = cc.Vec2.ZERO = Object.freeze(Vec2(0, 0));
114
+ var SpriteType;
115
+ (function (SpriteType) {
116
+ SpriteType[SpriteType["SIMPLE"] = 0] = "SIMPLE";
117
+ SpriteType[SpriteType["SLICED"] = 1] = "SLICED";
118
+ SpriteType[SpriteType["TILED"] = 2] = "TILED";
119
+ SpriteType[SpriteType["FILLED"] = 3] = "FILLED";
120
+ SpriteType[SpriteType["MESH"] = 4] = "MESH";
121
+ })(SpriteType || (exports.SpriteType = SpriteType = {}));
122
+ exports.RED = Color4B(255, 0, 0, 255);
123
+ exports.BLACK = Color4B(0, 0, 0, 255);
124
+ exports.WHITE = Color4B(255, 255, 255, 255);
125
+ exports.GREEN = Color4B(0, 255, 0, 255);
126
+ exports.BLUE = Color4B(0, 0, 255, 255);
127
+ cc.Color.DEBUG_FILL_COLOR = cc.color(255, 255, 0, 150);
128
+ cc.Color.DEBUG_BORDER_COLOR = cc.color(255, 0, 0, 255);
129
+ cc.Color.prototype.fromHEX = cc.hexToColor;
130
+ cc.Intersection = {
131
+ polygonPolygon: Intersection_1.polygonPolygon,
132
+ circleCircle: Intersection_1.circleCircle,
133
+ polygonCircle: Intersection_1.polygonCircle,
134
+ pointInPolygon: Intersection_1.pointInPolygon,
135
+ };
136
+ function Color4B(r, g, b, a) {
137
+ return cc.color(r, g, b, a);
138
+ }
139
+ var _Size = /** @class */ (function () {
140
+ function _Size(width, height) {
141
+ if (width === void 0) { width = 0; }
142
+ if (height === void 0) { height = 0; }
143
+ if (!(this instanceof _Size)) {
144
+ return new _Size(width, height);
145
+ }
146
+ if (height === undefined) {
147
+ this.width = width.width;
148
+ this.height = width.height;
149
+ }
150
+ this.width = width;
151
+ this.height = height;
152
+ }
153
+ return _Size;
154
+ }());
155
+ function Size(x, y) {
156
+ return new _Size(x, y);
157
+ }
158
+ var Touch = /** @class */ (function (_super) {
159
+ __extends(Touch, _super);
160
+ function Touch() {
161
+ return _super !== null && _super.apply(this, arguments) || this;
162
+ }
163
+ return Touch;
164
+ }(cc.Touch));
165
+ exports.Touch = Touch;
166
+ function getWinSize() {
167
+ return cc.director.getWinSize();
168
+ }
@@ -0,0 +1,2 @@
1
+ export declare const Skeleton: any;
2
+ //# sourceMappingURL=CCSkeleton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CCSkeleton.d.ts","sourceRoot":"","sources":["../../src/spine/CCSkeleton.ts"],"names":[],"mappings":"AAiaA,eAAO,MAAM,QAAQ,KAAkB,CAAA"}
@@ -0,0 +1,380 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.Skeleton = void 0;
37
+ var spine = __importStar(require("@esotericsoftware/spine-core"));
38
+ var spine_core_1 = require("@esotericsoftware/spine-core");
39
+ var CCSkeletonAnimation_1 = require("./CCSkeletonAnimation");
40
+ var CCSkeletonWebGLRenderCmd_1 = require("./CCSkeletonWebGLRenderCmd");
41
+ /****************************************************************************
42
+ Copyright (c) 2011-2012 cocos2d-x.org
43
+ Copyright (c) 2013-2014 Chukong Technologies Inc.
44
+ Copyright (c) 2014 Shengxiang Chen (Nero Chan)
45
+
46
+ http://www.cocos2d-x.org
47
+
48
+ Permission is hereby granted, free of charge, to any person obtaining a copy
49
+ of this software and associated documentation files (the "Software"), to deal
50
+ in the Software without restriction, including without limitation the rights
51
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
52
+ copies of the Software, and to permit persons to whom the Software is
53
+ furnished to do so, subject to the following conditions:
54
+
55
+ The above copyright notice and this permission notice shall be included in
56
+ all copies or substantial portions of the Software.
57
+
58
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
59
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
60
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
61
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
62
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
63
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
64
+ THE SOFTWARE.
65
+ ****************************************************************************/
66
+ /**
67
+ * The main namespace of Spine, all classes, functions, properties and constants of Spine are defined in this namespace
68
+ * @namespace
69
+ * @name gworld
70
+ */
71
+ var gworld = gworld || {};
72
+ /**
73
+ * <p>
74
+ * The skeleton of Spine. <br/>
75
+ * Skeleton has a reference to a SkeletonData and stores the state for skeleton instance,
76
+ * which consists of the current pose's bone SRT, slot colors, and which slot attachments are visible. <br/>
77
+ * Multiple skeletons can use the same SkeletonData (which includes all animations, skins, and attachments). <br/>
78
+ * </p>
79
+ * @class
80
+ * @extends cc.Node
81
+ */
82
+ gworld.Skeleton = cc.Node.extend(
83
+ /** @lends gworld.Skeleton# */ {
84
+ _skeleton: null,
85
+ _rootBone: null,
86
+ _timeScale: 1,
87
+ _debugSlots: false,
88
+ _debugBones: false,
89
+ _premultipliedAlpha: false,
90
+ _ownsSkeletonData: null,
91
+ _atlas: null,
92
+ /**
93
+ * The constructor of gworld.Skeleton. override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
94
+ */
95
+ ctor: function (skeletonDataFile, atlasFile, scale) {
96
+ cc.Node.prototype.ctor.call(this);
97
+ if (arguments.length === 0)
98
+ this.init();
99
+ else
100
+ this.initWithArgs(skeletonDataFile, atlasFile, scale);
101
+ },
102
+ _createRenderCmd: function () {
103
+ if (cc._renderType === cc.game.RENDER_TYPE_CANVAS)
104
+ return new gworld.Skeleton.CanvasRenderCmd(this);
105
+ else
106
+ return new CCSkeletonWebGLRenderCmd_1.WebGLRenderCmd(this);
107
+ },
108
+ /**
109
+ * Initializes a gworld.Skeleton. please do not call this function by yourself, you should pass the parameters to constructor to initialize it.
110
+ */
111
+ init: function () {
112
+ cc.Node.prototype.init.call(this);
113
+ this._premultipliedAlpha = cc._renderType === cc.game.RENDER_TYPE_WEBGL && cc.OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA;
114
+ },
115
+ onEnter: function () {
116
+ cc.Node.prototype.onEnter.call(this);
117
+ this.scheduleUpdate();
118
+ },
119
+ onExit: function () {
120
+ this.unscheduleUpdate();
121
+ cc.Node.prototype.onExit.call(this);
122
+ },
123
+ /**
124
+ * Sets whether open debug slots.
125
+ * @param {boolean} enable true to open, false to close.
126
+ */
127
+ setDebugSolots: function (enable) {
128
+ this._debugSlots = enable;
129
+ },
130
+ /**
131
+ * Sets whether open debug bones.
132
+ * @param {boolean} enable
133
+ */
134
+ setDebugBones: function (enable) {
135
+ this._debugBones = enable;
136
+ },
137
+ /**
138
+ * Sets whether open debug slots.
139
+ * @param {boolean} enabled true to open, false to close.
140
+ */
141
+ setDebugSlotsEnabled: function (enabled) {
142
+ this._debugSlots = enabled;
143
+ },
144
+ /**
145
+ * Gets whether open debug slots.
146
+ * @returns {boolean} true to open, false to close.
147
+ */
148
+ getDebugSlotsEnabled: function () {
149
+ return this._debugSlots;
150
+ },
151
+ /**
152
+ * Sets whether open debug bones.
153
+ * @param {boolean} enabled
154
+ */
155
+ setDebugBonesEnabled: function (enabled) {
156
+ this._debugBones = enabled;
157
+ },
158
+ /**
159
+ * Gets whether open debug bones.
160
+ * @returns {boolean} true to open, false to close.
161
+ */
162
+ getDebugBonesEnabled: function () {
163
+ return this._debugBones;
164
+ },
165
+ /**
166
+ * Sets the time scale of gworld.Skeleton.
167
+ * @param {Number} scale
168
+ */
169
+ setTimeScale: function (scale) {
170
+ this._timeScale = scale;
171
+ },
172
+ getTimeScale: function () {
173
+ return this._timeScale;
174
+ },
175
+ /**
176
+ * Initializes gworld.Skeleton with Data.
177
+ * @param {gworld.spine.SkeletonData|String} skeletonDataFile
178
+ * @param {String|spine.Atlas|spine.SkeletonData} atlasFile atlas filename or atlas data or owns SkeletonData
179
+ * @param {Number} [scale] scale can be specified on the JSON or binary loader which will scale the bone positions, image sizes, and animation translations.
180
+ */
181
+ initWithArgs: function (skeletonDataFile, atlasFile, scale) {
182
+ var argSkeletonFile = skeletonDataFile, argAtlasFile = atlasFile, skeletonData, atlas, ownsSkeletonData;
183
+ if (cc.isString(argSkeletonFile)) {
184
+ if (cc.isString(argAtlasFile)) {
185
+ var data = cc.loader.getRes(argAtlasFile);
186
+ CCSkeletonAnimation_1._atlasLoader.setAtlasFile(argAtlasFile);
187
+ atlas = new spine_core_1.TextureAtlas(data);
188
+ for (var _i = 0, _a = atlas.pages; _i < _a.length; _i++) {
189
+ var page = _a[_i];
190
+ var texture = CCSkeletonAnimation_1._atlasLoader.load(page.name);
191
+ page.setTexture(texture);
192
+ }
193
+ }
194
+ scale = scale || 1 / cc.director.getContentScaleFactor();
195
+ var attachmentLoader = new spine_core_1.AtlasAttachmentLoader(atlas);
196
+ var skeletonJsonReader = new spine_core_1.SkeletonJson(attachmentLoader);
197
+ skeletonJsonReader.scale = scale;
198
+ var skeletonJson = cc.loader.getRes(argSkeletonFile);
199
+ skeletonData = skeletonJsonReader.readSkeletonData(skeletonJson);
200
+ atlas.dispose(skeletonJsonReader);
201
+ ownsSkeletonData = true;
202
+ }
203
+ else {
204
+ skeletonData = skeletonDataFile;
205
+ ownsSkeletonData = atlasFile;
206
+ }
207
+ this.setSkeletonData(skeletonData, ownsSkeletonData);
208
+ this.init();
209
+ },
210
+ /**
211
+ * Returns the bounding box of gworld.Skeleton.
212
+ * @returns {cc.Rect}
213
+ */
214
+ getBoundingBox: function () {
215
+ var minX = cc.FLT_MAX, minY = cc.FLT_MAX, maxX = cc.FLT_MIN, maxY = cc.FLT_MIN;
216
+ var scaleX = this.getScaleX(), scaleY = this.getScaleY(), vertices, slots = this._skeleton.slots, VERTEX = spine.RegionAttachment;
217
+ for (var i = 0, slotCount = slots.length; i < slotCount; ++i) {
218
+ var slot = slots[i];
219
+ var attachment = slot.attachment;
220
+ if (!attachment || !(attachment instanceof spine.RegionAttachment))
221
+ continue;
222
+ vertices = spine.Utils.setArraySize([], 8, 0);
223
+ attachment.computeWorldVertices(slot, vertices, 0, 2);
224
+ minX = Math.min(minX, vertices[VERTEX.X1] * scaleX, vertices[VERTEX.X4] * scaleX, vertices[VERTEX.X2] * scaleX, vertices[VERTEX.X3] * scaleX);
225
+ minY = Math.min(minY, vertices[VERTEX.Y1] * scaleY, vertices[VERTEX.Y4] * scaleY, vertices[VERTEX.Y2] * scaleY, vertices[VERTEX.Y3] * scaleY);
226
+ maxX = Math.max(maxX, vertices[VERTEX.X1] * scaleX, vertices[VERTEX.X4] * scaleX, vertices[VERTEX.X2] * scaleX, vertices[VERTEX.X3] * scaleX);
227
+ maxY = Math.max(maxY, vertices[VERTEX.Y1] * scaleY, vertices[VERTEX.Y4] * scaleY, vertices[VERTEX.Y2] * scaleY, vertices[VERTEX.Y3] * scaleY);
228
+ }
229
+ var position = this.getPosition();
230
+ return cc.rect(position.x + minX, position.y + minY, maxX - minX, maxY - minY);
231
+ },
232
+ /**
233
+ * Computes the world SRT from the local SRT for each bone.
234
+ */
235
+ updateWorldTransform: function () {
236
+ this._skeleton.updateWorldTransform(true);
237
+ },
238
+ /**
239
+ * Sets the bones and slots to the setup pose.
240
+ */
241
+ setToSetupPose: function () {
242
+ this._skeleton.setToSetupPose();
243
+ },
244
+ /**
245
+ * Sets the bones to the setup pose, using the values from the `BoneData` list in the `SkeletonData`.
246
+ */
247
+ setBonesToSetupPose: function () {
248
+ this._skeleton.setBonesToSetupPose();
249
+ },
250
+ /**
251
+ * Sets the slots to the setup pose, using the values from the `SlotData` list in the `SkeletonData`.
252
+ */
253
+ setSlotsToSetupPose: function () {
254
+ this._skeleton.setSlotsToSetupPose();
255
+ },
256
+ /**
257
+ * Finds a bone by name. This does a string comparison for every bone.
258
+ * @param {String} boneName
259
+ * @returns {gworld.spine.Bone}
260
+ */
261
+ findBone: function (boneName) {
262
+ return this._skeleton.findBone(boneName);
263
+ },
264
+ /**
265
+ * Finds a slot by name. This does a string comparison for every slot.
266
+ * @param {String} slotName
267
+ * @returns {gworld.spine.Slot}
268
+ */
269
+ findSlot: function (slotName) {
270
+ return this._skeleton.findSlot(slotName);
271
+ },
272
+ /**
273
+ * Finds a skin by name and makes it the active skin. This does a string comparison for every skin. Note that setting the skin does not change which attachments are visible.
274
+ * @param {string} skinName
275
+ * @returns {gworld.spine.Skin}
276
+ */
277
+ setSkin: function (skinName) {
278
+ return this._skeleton.setSkinByName(skinName);
279
+ },
280
+ /**
281
+ * Returns the attachment for the slot and attachment name. The skeleton looks first in its skin, then in the skeleton data’s default skin.
282
+ * @param {String} slotName
283
+ * @param {String} attachmentName
284
+ * @returns {gworld.spine.Attachment}
285
+ */
286
+ getAttachment: function (slotName, attachmentName) {
287
+ return this._skeleton.getAttachmentByName(slotName, attachmentName);
288
+ },
289
+ /**
290
+ * Sets the attachment for the slot and attachment name. The skeleton looks first in its skin, then in the skeleton data’s default skin.
291
+ * @param {String} slotName
292
+ * @param {String} attachmentName
293
+ */
294
+ setAttachment: function (slotName, attachmentName) {
295
+ this._skeleton.setAttachment(slotName, attachmentName);
296
+ },
297
+ /**
298
+ * Sets the premultiplied alpha value to gworld.Skeleton.
299
+ * @param {Number} alpha
300
+ */
301
+ setPremultipliedAlpha: function (premultiplied) {
302
+ this._premultipliedAlpha = premultiplied;
303
+ },
304
+ /**
305
+ * Returns whether to enable premultiplied alpha.
306
+ * @returns {boolean}
307
+ */
308
+ isPremultipliedAlpha: function () {
309
+ return this._premultipliedAlpha;
310
+ },
311
+ /**
312
+ * Sets skeleton data to gworld.Skeleton.
313
+ * @param {gworld.spine.SkeletonData} skeletonData
314
+ * @param {gworld.spine.SkeletonData} ownsSkeletonData
315
+ */
316
+ setSkeletonData: function (skeletonData, ownsSkeletonData) {
317
+ if (skeletonData.width != null && skeletonData.height != null)
318
+ this.setContentSize(skeletonData.width / cc.director.getContentScaleFactor(), skeletonData.height / cc.director.getContentScaleFactor());
319
+ this._skeleton = new spine.Skeleton(skeletonData);
320
+ this._skeleton.updateWorldTransform(true);
321
+ this._rootBone = this._skeleton.getRootBone();
322
+ this._ownsSkeletonData = ownsSkeletonData;
323
+ this._renderCmd._createChildFormSkeletonData();
324
+ },
325
+ /**
326
+ * Return the renderer of attachment.
327
+ * @param {gworld.spine.RegionAttachment|gworld.spine.BoundingBoxAttachment} regionAttachment
328
+ * @returns {gworld.spine.TextureAtlasRegion}
329
+ */
330
+ getTextureAtlas: function (regionAttachment) {
331
+ return regionAttachment.region;
332
+ },
333
+ /**
334
+ * Returns the blendFunc of gworld.Skeleton.
335
+ * @returns {cc.BlendFunc}
336
+ */
337
+ getBlendFunc: function () {
338
+ var slot = this._skeleton.drawOrder[0];
339
+ if (slot) {
340
+ var blend = this._renderCmd._getBlendFunc(slot.data.blendMode, this._premultipliedAlpha);
341
+ return blend;
342
+ }
343
+ else {
344
+ return {};
345
+ }
346
+ },
347
+ /**
348
+ * Sets the blendFunc of gworld.Skeleton, it won't have any effect for skeleton, skeleton is using slot's data to determine the blend function.
349
+ * @param {cc.BlendFunc|Number} src
350
+ * @param {Number} [dst]
351
+ */
352
+ setBlendFunc: function (src, dst) {
353
+ return;
354
+ },
355
+ /**
356
+ * Update will be called automatically every frame if "scheduleUpdate" is called when the node is "live".
357
+ * @param {Number} dt Delta time since last update
358
+ */
359
+ update: function (dt) {
360
+ this._skeleton.update(dt);
361
+ },
362
+ });
363
+ cc.defineGetterSetter(gworld.Skeleton.prototype, 'opacityModifyRGB', gworld.Skeleton.prototype.isOpacityModifyRGB);
364
+ // For renderer webgl to identify skeleton's default texture and blend function
365
+ cc.defineGetterSetter(gworld.Skeleton.prototype, '_blendFunc', gworld.Skeleton.prototype.getBlendFunc);
366
+ cc.defineGetterSetter(gworld.Skeleton.prototype, '_texture', function () {
367
+ return this._renderCmd._currTexture;
368
+ });
369
+ /**
370
+ * Creates a skeleton object.
371
+ * @deprecated since v3.0, please use new gworld.Skeleton(skeletonDataFile, atlasFile, scale) instead.
372
+ * @param {spine.SkeletonData|String} skeletonDataFile
373
+ * @param {String|spine.Atlas|spine.SkeletonData} atlasFile atlas filename or atlas data or owns SkeletonData
374
+ * @param {Number} [scale] scale can be specified on the JSON or binary loader which will scale the bone positions, image sizes, and animation translations.
375
+ * @returns {gworld.Skeleton}
376
+ */
377
+ gworld.Skeleton.create = function (skeletonDataFile, atlasFile /* or atlas*/, scale) {
378
+ return new gworld.Skeleton(skeletonDataFile, atlasFile, scale);
379
+ };
380
+ exports.Skeleton = gworld.Skeleton;
@@ -0,0 +1,16 @@
1
+ export declare const _atlasLoader: {
2
+ spAtlasFile: any;
3
+ setAtlasFile: (spAtlasFile: any) => void;
4
+ load: (line: any) => any;
5
+ unload: (obj: any) => void;
6
+ };
7
+ /**
8
+ * The skeleton animation of spine. It updates animation's state and skeleton's world transform.
9
+ * @class
10
+ * @extends gworld.Skeleton
11
+ * @example
12
+ * var spineBoy = new SkeletonAnimation('res/skeletons/spineboy.json', 'res/skeletons/spineboy.atlas');
13
+ * this.addChild(spineBoy, 4);
14
+ */
15
+ export declare const SkeletonAnimation: any;
16
+ //# sourceMappingURL=CCSkeletonAnimation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CCSkeletonAnimation.d.ts","sourceRoot":"","sources":["../../src/spine/CCSkeletonAnimation.ts"],"names":[],"mappings":"AA+BA,eAAO,MAAM,YAAY;;;;;CAaxB,CAAA;AA2FD;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,KAuM5B,CAAA"}