@safe-engine/cocos 1.5.3 → 1.5.7
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.
- package/dist/animation/AnimationComponent.js +53 -75
- package/dist/animation/AnimationSystem.js +15 -23
- package/dist/animation/index.js +6 -9
- package/dist/app.js +37 -64
- package/dist/box2d-wasm/ContactListener.d.ts +12 -0
- package/dist/box2d-wasm/ContactListener.d.ts.map +1 -0
- package/dist/box2d-wasm/ContactListener.js +96 -0
- package/dist/box2d-wasm/PhysicsComponent.d.ts +44 -0
- package/dist/box2d-wasm/PhysicsComponent.d.ts.map +1 -0
- package/dist/box2d-wasm/PhysicsComponent.js +14 -0
- package/dist/box2d-wasm/PhysicsSprite.d.ts +12 -0
- package/dist/box2d-wasm/PhysicsSprite.d.ts.map +1 -0
- package/dist/box2d-wasm/PhysicsSprite.js +51 -0
- package/dist/box2d-wasm/PhysicsSystem.d.ts +18 -0
- package/dist/box2d-wasm/PhysicsSystem.d.ts.map +1 -0
- package/dist/box2d-wasm/PhysicsSystem.js +237 -0
- package/dist/box2d-wasm/debugDraw.d.ts +66 -0
- package/dist/box2d-wasm/debugDraw.d.ts.map +1 -0
- package/dist/box2d-wasm/debugDraw.js +210 -0
- package/dist/box2d-wasm/index.d.ts +6 -0
- package/dist/box2d-wasm/index.d.ts.map +1 -0
- package/dist/box2d-wasm/index.js +10 -0
- package/dist/collider/CollideComponent.js +98 -159
- package/dist/collider/CollideSystem.js +63 -79
- package/dist/collider/index.js +7 -11
- package/dist/dragonbones/PixiDragonBonesSprite.js +15 -19
- package/dist/dragonbones/index.js +38 -68
- package/dist/gworld/components/AnimationComponent.d.ts +2 -2
- package/dist/gworld/components/CollideComponent.d.ts +3 -3
- package/dist/gworld/components/EnhancedComponent.js +29 -36
- package/dist/gworld/components/GUIComponent.js +50 -118
- package/dist/gworld/components/NoRenderComponent.js +25 -65
- package/dist/gworld/components/NodeComp.d.ts.map +1 -1
- package/dist/gworld/components/NodeComp.js +237 -317
- package/dist/gworld/components/RenderComponent.js +46 -104
- package/dist/gworld/core/NodePool.js +13 -20
- package/dist/gworld/core/Scene.js +11 -35
- package/dist/gworld/core/decorator.js +12 -42
- package/dist/gworld/index.js +13 -42
- package/dist/gworld/systems/CollideSystem.d.ts +1 -2
- package/dist/gworld/systems/CollideSystem.d.ts.map +1 -1
- package/dist/gworld/systems/CollideSystem.js +2 -12
- package/dist/gworld/systems/GUISystem.js +105 -120
- package/dist/gworld/systems/NoRenderSystem.d.ts.map +1 -1
- package/dist/gworld/systems/NoRenderSystem.js +70 -80
- package/dist/gworld/systems/RenderSystem.js +64 -78
- package/dist/helper/Intersection.js +33 -40
- package/dist/helper/action.js +8 -21
- package/dist/helper/director.js +2 -6
- package/dist/helper/math.js +9 -15
- package/dist/helper/utils.js +28 -37
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -31
- package/dist/polyfills.js +69 -97
- package/dist/richtext/RichTextComp.js +27 -55
- package/dist/richtext/RichTextSystem.js +17 -25
- package/dist/richtext/html-text-parser.js +36 -40
- package/dist/richtext/index.js +5 -8
- package/dist/safex.js +1 -2
- package/dist/spine/CCSkeleton.d.ts.map +1 -1
- package/dist/spine/CCSkeleton.js +25 -61
- package/dist/spine/CCSkeletonAnimation.js +18 -54
- package/dist/spine/CCSkeletonCanvasRenderCmd.d.ts +1 -1
- package/dist/spine/CCSkeletonCanvasRenderCmd.d.ts.map +1 -1
- package/dist/spine/CCSkeletonCanvasRenderCmd.js +39 -43
- package/dist/spine/CCSkeletonTexture.js +4 -40
- package/dist/spine/CCSkeletonWebGLRenderCmd.js +56 -92
- package/dist/spine/index.js +37 -63
- package/package.json +4 -1
- package/dist/dragonbones/cocos/CocosArmatureDisplay.d.ts +0 -77
- package/dist/dragonbones/cocos/CocosArmatureDisplay.d.ts.map +0 -1
- package/dist/dragonbones/cocos/CocosArmatureDisplay.js +0 -227
- package/dist/dragonbones/cocos/CocosFactory.d.ts +0 -128
- package/dist/dragonbones/cocos/CocosFactory.d.ts.map +0 -1
- package/dist/dragonbones/cocos/CocosFactory.js +0 -231
- package/dist/dragonbones/cocos/CocosSlot.d.ts +0 -49
- package/dist/dragonbones/cocos/CocosSlot.d.ts.map +0 -1
- package/dist/dragonbones/cocos/CocosSlot.js +0 -385
- package/dist/dragonbones/cocos/CocosTextureAtlasData.d.ts +0 -53
- package/dist/dragonbones/cocos/CocosTextureAtlasData.d.ts.map +0 -1
- package/dist/dragonbones/cocos/CocosTextureAtlasData.js +0 -158
- package/dist/dragonbones/dragonBones.d.ts +0 -3
- package/dist/dragonbones/dragonBones.d.ts.map +0 -1
- package/dist/dragonbones/dragonBones.js +0 -4788
- package/dist/helper/NodePool.d.ts +0 -9
- package/dist/helper/NodePool.d.ts.map +0 -1
- package/dist/helper/NodePool.js +0 -29
|
@@ -1,57 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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.RichTextComp = void 0;
|
|
19
|
-
var decorator_1 = require("../gworld/core/decorator");
|
|
20
|
-
var html_text_parser_1 = require("./html-text-parser");
|
|
21
|
-
var _htmlTextParser = new html_text_parser_1.HtmlTextParser();
|
|
22
|
-
var RichTextComp = /** @class */ (function (_super) {
|
|
23
|
-
__extends(RichTextComp, _super);
|
|
24
|
-
function RichTextComp() {
|
|
25
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
1
|
+
import { ComponentX } from '../gworld/core/decorator';
|
|
2
|
+
import { HtmlTextParser } from './html-text-parser';
|
|
3
|
+
const _htmlTextParser = new HtmlTextParser();
|
|
4
|
+
export class RichTextComp extends ComponentX {
|
|
5
|
+
get string() {
|
|
6
|
+
return this.props.string;
|
|
26
7
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
this.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
this.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
console.log('richText', richText);
|
|
46
|
-
// this.node.instance._addNewLine()
|
|
47
|
-
// }
|
|
48
|
-
this.node.instance.pushBackElement(richText);
|
|
49
|
-
}
|
|
8
|
+
set string(val) {
|
|
9
|
+
this.props.string = val;
|
|
10
|
+
if (this.node.instance instanceof ccui.RichText) {
|
|
11
|
+
const newTextArray = _htmlTextParser.parse(val);
|
|
12
|
+
console.log(newTextArray);
|
|
13
|
+
this.node.instance._richElements = [];
|
|
14
|
+
this.node.instance._formatTextDirty = true;
|
|
15
|
+
this.node.instance.formatText();
|
|
16
|
+
for (let index = 0; index < newTextArray.length; index++) {
|
|
17
|
+
const { style, text } = newTextArray[index];
|
|
18
|
+
const color = style && style.color ? cc.hexToColor(style.color) : cc.Color.WHITE;
|
|
19
|
+
const fontName = cc.path.basename(this.props.font, '.ttf');
|
|
20
|
+
const richText = ccui.RichElementText.create(index, color, 255, text, fontName, this.props.size || 64);
|
|
21
|
+
// if (style && style.newline) {
|
|
22
|
+
console.log('richText', richText);
|
|
23
|
+
// this.node.instance._addNewLine()
|
|
24
|
+
// }
|
|
25
|
+
this.node.instance.pushBackElement(richText);
|
|
50
26
|
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
});
|
|
55
|
-
return RichTextComp;
|
|
56
|
-
}(decorator_1.ComponentX));
|
|
57
|
-
exports.RichTextComp = RichTextComp;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -1,28 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var RichTextSystem = /** @class */ (function () {
|
|
8
|
-
function RichTextSystem() {
|
|
9
|
-
this.onAddRichTextComp = function (_a) {
|
|
10
|
-
var entity = _a.entity, rich = _a.component;
|
|
11
|
-
var _b = rich.props.string, string = _b === void 0 ? '' : _b;
|
|
12
|
-
var node = new ccui.RichText();
|
|
13
|
-
node.width = 500;
|
|
14
|
-
node.height = 300;
|
|
15
|
-
node.ignoreContentAdaptWithSize(false);
|
|
16
|
-
rich.node = entity.assign(new __1.NodeComp(node, entity));
|
|
17
|
-
rich.string = string;
|
|
18
|
-
};
|
|
1
|
+
import { EventTypes } from 'entityx-ts';
|
|
2
|
+
import { NodeComp } from '..';
|
|
3
|
+
import { RichTextComp } from './RichTextComp';
|
|
4
|
+
export class RichTextSystem {
|
|
5
|
+
configure(event_manager) {
|
|
6
|
+
event_manager.subscribe(EventTypes.ComponentAdded, RichTextComp, this.onAddRichTextComp);
|
|
19
7
|
}
|
|
20
|
-
|
|
21
|
-
|
|
8
|
+
onAddRichTextComp = ({ entity, component: rich }) => {
|
|
9
|
+
const { string = '' } = rich.props;
|
|
10
|
+
const node = new ccui.RichText();
|
|
11
|
+
node.width = 500;
|
|
12
|
+
node.height = 300;
|
|
13
|
+
node.ignoreContentAdaptWithSize(false);
|
|
14
|
+
rich.node = entity.assign(new NodeComp(node, entity));
|
|
15
|
+
rich.string = string;
|
|
22
16
|
};
|
|
23
|
-
|
|
17
|
+
update() {
|
|
24
18
|
// throw new Error('Method not implemented.');
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
}());
|
|
28
|
-
exports.RichTextSystem = RichTextSystem;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/* eslint-disable no-var */
|
|
3
2
|
/* eslint-disable quotes */
|
|
4
3
|
/* eslint-disable no-useless-escape */
|
|
@@ -28,14 +27,12 @@
|
|
|
28
27
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
29
28
|
THE SOFTWARE.
|
|
30
29
|
****************************************************************************/
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
var eventRegx = /^(click)(\s)*=|(param)(\s)*=/;
|
|
34
|
-
var imageAttrReg = /(\s)*src(\s)*=|(\s)*height(\s)*=|(\s)*width(\s)*=|(\s)*align(\s)*=|(\s)*offset(\s)*=|(\s)*click(\s)*=|(\s)*param(\s)*=/;
|
|
30
|
+
const eventRegx = /^(click)(\s)*=|(param)(\s)*=/;
|
|
31
|
+
const imageAttrReg = /(\s)*src(\s)*=|(\s)*height(\s)*=|(\s)*width(\s)*=|(\s)*align(\s)*=|(\s)*offset(\s)*=|(\s)*click(\s)*=|(\s)*param(\s)*=/;
|
|
35
32
|
/**
|
|
36
33
|
* A utils class for parsing HTML texts. The parsed results will be an object array.
|
|
37
34
|
*/
|
|
38
|
-
|
|
35
|
+
export const HtmlTextParser = function () {
|
|
39
36
|
this._parsedObject = {};
|
|
40
37
|
this._specialSymbolArray = [];
|
|
41
38
|
this._specialSymbolArray.push([/</g, '<']);
|
|
@@ -45,23 +42,22 @@ var HtmlTextParser = function () {
|
|
|
45
42
|
this._specialSymbolArray.push([/'/g, "'"]);
|
|
46
43
|
this._specialSymbolArray.push([/ /g, ' ']);
|
|
47
44
|
};
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
constructor: exports.HtmlTextParser,
|
|
45
|
+
HtmlTextParser.prototype = {
|
|
46
|
+
constructor: HtmlTextParser,
|
|
51
47
|
parse: function (htmlString) {
|
|
52
48
|
this._resultObjectArray = [];
|
|
53
49
|
if (!htmlString) {
|
|
54
50
|
return this._resultObjectArray;
|
|
55
51
|
}
|
|
56
52
|
this._stack = [];
|
|
57
|
-
|
|
58
|
-
|
|
53
|
+
let startIndex = 0;
|
|
54
|
+
const length = htmlString.length;
|
|
59
55
|
while (startIndex < length) {
|
|
60
|
-
|
|
61
|
-
|
|
56
|
+
let tagEndIndex = htmlString.indexOf('>', startIndex);
|
|
57
|
+
let tagBeginIndex = -1;
|
|
62
58
|
if (tagEndIndex >= 0) {
|
|
63
59
|
tagBeginIndex = htmlString.lastIndexOf('<', tagEndIndex);
|
|
64
|
-
|
|
60
|
+
const noTagBegin = tagBeginIndex < startIndex - 1;
|
|
65
61
|
if (noTagBegin) {
|
|
66
62
|
tagBeginIndex = htmlString.indexOf('<', tagEndIndex + 1);
|
|
67
63
|
tagEndIndex = htmlString.indexOf('>', tagBeginIndex + 1);
|
|
@@ -73,8 +69,8 @@ exports.HtmlTextParser.prototype = {
|
|
|
73
69
|
startIndex = length;
|
|
74
70
|
}
|
|
75
71
|
else {
|
|
76
|
-
|
|
77
|
-
|
|
72
|
+
let newStr = htmlString.substring(startIndex, tagBeginIndex);
|
|
73
|
+
const tagStr = htmlString.substring(tagBeginIndex + 1, tagEndIndex);
|
|
78
74
|
if (tagStr === '')
|
|
79
75
|
newStr = htmlString.substring(startIndex, tagEndIndex + 1);
|
|
80
76
|
this._processResult(newStr);
|
|
@@ -95,12 +91,12 @@ exports.HtmlTextParser.prototype = {
|
|
|
95
91
|
},
|
|
96
92
|
_attributeToObject: function (attribute) {
|
|
97
93
|
attribute = attribute.trim();
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
94
|
+
const obj = {};
|
|
95
|
+
let header = attribute.match(/^(color|size)(\s)*=/);
|
|
96
|
+
let tagName;
|
|
97
|
+
let nextSpace;
|
|
98
|
+
let eventObj;
|
|
99
|
+
let eventHanlderString;
|
|
104
100
|
if (header) {
|
|
105
101
|
tagName = header[0];
|
|
106
102
|
attribute = attribute.substring(tagName.length).trim();
|
|
@@ -145,7 +141,7 @@ exports.HtmlTextParser.prototype = {
|
|
|
145
141
|
header = attribute.match(imageAttrReg);
|
|
146
142
|
var tagValue;
|
|
147
143
|
var remainingArgument;
|
|
148
|
-
|
|
144
|
+
let isValidImageTag = false;
|
|
149
145
|
while (header) {
|
|
150
146
|
//skip the invalid tags at first
|
|
151
147
|
attribute = attribute.substring(attribute.indexOf(header[0]));
|
|
@@ -189,7 +185,7 @@ exports.HtmlTextParser.prototype = {
|
|
|
189
185
|
obj.imageOffset = tagValue;
|
|
190
186
|
}
|
|
191
187
|
else if (tagName === 'click') {
|
|
192
|
-
obj.event = this._processEventHandler(
|
|
188
|
+
obj.event = this._processEventHandler(`${tagName}=${tagValue}`);
|
|
193
189
|
}
|
|
194
190
|
if (obj.event && tagName === 'param') {
|
|
195
191
|
obj.event.param = tagValue.replace(/^\"|\"$/g, '');
|
|
@@ -205,9 +201,9 @@ exports.HtmlTextParser.prototype = {
|
|
|
205
201
|
header = attribute.match(/^(outline(\s)*[^>]*)/);
|
|
206
202
|
if (header) {
|
|
207
203
|
attribute = header[0].substring('outline'.length).trim();
|
|
208
|
-
|
|
204
|
+
const defaultOutlineObject = { color: '#ffffff', width: 1 };
|
|
209
205
|
if (attribute) {
|
|
210
|
-
|
|
206
|
+
const outlineAttrReg = /(\s)*color(\s)*=|(\s)*width(\s)*=|(\s)*click(\s)*=|(\s)*param(\s)*=/;
|
|
211
207
|
header = attribute.match(outlineAttrReg);
|
|
212
208
|
var tagValue;
|
|
213
209
|
while (header) {
|
|
@@ -227,7 +223,7 @@ exports.HtmlTextParser.prototype = {
|
|
|
227
223
|
tagName = tagName.toLocaleLowerCase();
|
|
228
224
|
attribute = remainingArgument.substring(nextSpace).trim();
|
|
229
225
|
if (tagName === 'click') {
|
|
230
|
-
obj.event = this._processEventHandler(
|
|
226
|
+
obj.event = this._processEventHandler(`${tagName}=${tagValue}`);
|
|
231
227
|
}
|
|
232
228
|
else if (tagName === 'color') {
|
|
233
229
|
defaultOutlineObject.color = tagValue;
|
|
@@ -267,13 +263,13 @@ exports.HtmlTextParser.prototype = {
|
|
|
267
263
|
return obj;
|
|
268
264
|
},
|
|
269
265
|
_processEventHandler: function (eventString) {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
266
|
+
let index = 0;
|
|
267
|
+
const obj = {};
|
|
268
|
+
let eventNames = eventString.match(eventRegx);
|
|
269
|
+
let isValidTag = false;
|
|
274
270
|
while (eventNames) {
|
|
275
|
-
|
|
276
|
-
|
|
271
|
+
let eventName = eventNames[0];
|
|
272
|
+
let eventValue = '';
|
|
277
273
|
isValidTag = false;
|
|
278
274
|
eventString = eventString.substring(eventName.length).trim();
|
|
279
275
|
if (eventString.charAt(0) === '"') {
|
|
@@ -294,7 +290,7 @@ exports.HtmlTextParser.prototype = {
|
|
|
294
290
|
}
|
|
295
291
|
else {
|
|
296
292
|
//skip the invalid attribute value
|
|
297
|
-
|
|
293
|
+
const match = eventString.match(/(\S)+/);
|
|
298
294
|
if (match) {
|
|
299
295
|
eventValue = match[0];
|
|
300
296
|
}
|
|
@@ -313,7 +309,7 @@ exports.HtmlTextParser.prototype = {
|
|
|
313
309
|
return obj;
|
|
314
310
|
},
|
|
315
311
|
_addToStack: function (attribute) {
|
|
316
|
-
|
|
312
|
+
const obj = this._attributeToObject(attribute);
|
|
317
313
|
if (this._stack.length === 0) {
|
|
318
314
|
this._stack.push(obj);
|
|
319
315
|
}
|
|
@@ -322,8 +318,8 @@ exports.HtmlTextParser.prototype = {
|
|
|
322
318
|
return;
|
|
323
319
|
}
|
|
324
320
|
//for nested tags
|
|
325
|
-
|
|
326
|
-
for (
|
|
321
|
+
const previousTagObj = this._stack[this._stack.length - 1];
|
|
322
|
+
for (const key in previousTagObj) {
|
|
327
323
|
if (!obj[key]) {
|
|
328
324
|
obj[key] = previousTagObj[key];
|
|
329
325
|
}
|
|
@@ -344,9 +340,9 @@ exports.HtmlTextParser.prototype = {
|
|
|
344
340
|
}
|
|
345
341
|
},
|
|
346
342
|
_escapeSpecialSymbol: function (str) {
|
|
347
|
-
for (
|
|
348
|
-
|
|
349
|
-
|
|
343
|
+
for (let i = 0; i < this._specialSymbolArray.length; ++i) {
|
|
344
|
+
const key = this._specialSymbolArray[i][0];
|
|
345
|
+
const value = this._specialSymbolArray[i][1];
|
|
350
346
|
str = str.replace(key, value);
|
|
351
347
|
}
|
|
352
348
|
return str;
|
package/dist/richtext/index.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
function setupRichText() {
|
|
7
|
-
gworld_1.GameWorld.Instance.systems.add(RichTextSystem_1.RichTextSystem);
|
|
8
|
-
gworld_1.GameWorld.Instance.systems.configureOnce(RichTextSystem_1.RichTextSystem);
|
|
1
|
+
import { GameWorld } from '../gworld';
|
|
2
|
+
import { RichTextSystem } from './RichTextSystem';
|
|
3
|
+
export function setupRichText() {
|
|
4
|
+
GameWorld.Instance.systems.add(RichTextSystem);
|
|
5
|
+
GameWorld.Instance.systems.configureOnce(RichTextSystem);
|
|
9
6
|
}
|
package/dist/safex.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CCSkeleton.d.ts","sourceRoot":"","sources":["../../src/spine/CCSkeleton.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CCSkeleton.d.ts","sourceRoot":"","sources":["../../src/spine/CCSkeleton.ts"],"names":[],"mappings":"AAkaA,eAAO,MAAM,QAAQ,KAAkB,CAAA"}
|
package/dist/spine/CCSkeleton.js
CHANGED
|
@@ -1,43 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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");
|
|
1
|
+
import * as spine from '@esotericsoftware/spine-core';
|
|
2
|
+
import { AtlasAttachmentLoader, SkeletonJson, TextureAtlas } from '@esotericsoftware/spine-core';
|
|
3
|
+
import { _atlasLoader } from './CCSkeletonAnimation';
|
|
4
|
+
import { CanvasRenderCmd } from './CCSkeletonCanvasRenderCmd';
|
|
5
|
+
import { WebGLRenderCmd } from './CCSkeletonWebGLRenderCmd';
|
|
41
6
|
/****************************************************************************
|
|
42
7
|
Copyright (c) 2011-2012 cocos2d-x.org
|
|
43
8
|
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
|
@@ -101,9 +66,9 @@ gworld.Skeleton = cc.Node.extend(
|
|
|
101
66
|
},
|
|
102
67
|
_createRenderCmd: function () {
|
|
103
68
|
if (cc._renderType === cc.game.RENDER_TYPE_CANVAS)
|
|
104
|
-
return new
|
|
69
|
+
return new CanvasRenderCmd(this);
|
|
105
70
|
else
|
|
106
|
-
return new
|
|
71
|
+
return new WebGLRenderCmd(this);
|
|
107
72
|
},
|
|
108
73
|
/**
|
|
109
74
|
* Initializes a gworld.Skeleton. please do not call this function by yourself, you should pass the parameters to constructor to initialize it.
|
|
@@ -179,23 +144,22 @@ gworld.Skeleton = cc.Node.extend(
|
|
|
179
144
|
* @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
145
|
*/
|
|
181
146
|
initWithArgs: function (skeletonDataFile, atlasFile, scale) {
|
|
182
|
-
|
|
147
|
+
let argSkeletonFile = skeletonDataFile, argAtlasFile = atlasFile, skeletonData, atlas, ownsSkeletonData;
|
|
183
148
|
if (cc.isString(argSkeletonFile)) {
|
|
184
149
|
if (cc.isString(argAtlasFile)) {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
atlas = new
|
|
188
|
-
for (
|
|
189
|
-
|
|
190
|
-
var texture = CCSkeletonAnimation_1._atlasLoader.load(page.name);
|
|
150
|
+
const data = cc.loader.getRes(argAtlasFile);
|
|
151
|
+
_atlasLoader.setAtlasFile(argAtlasFile);
|
|
152
|
+
atlas = new TextureAtlas(data);
|
|
153
|
+
for (const page of atlas.pages) {
|
|
154
|
+
const texture = _atlasLoader.load(page.name);
|
|
191
155
|
page.setTexture(texture);
|
|
192
156
|
}
|
|
193
157
|
}
|
|
194
158
|
scale = scale || 1 / cc.director.getContentScaleFactor();
|
|
195
|
-
|
|
196
|
-
|
|
159
|
+
const attachmentLoader = new AtlasAttachmentLoader(atlas);
|
|
160
|
+
const skeletonJsonReader = new SkeletonJson(attachmentLoader);
|
|
197
161
|
skeletonJsonReader.scale = scale;
|
|
198
|
-
|
|
162
|
+
const skeletonJson = cc.loader.getRes(argSkeletonFile);
|
|
199
163
|
skeletonData = skeletonJsonReader.readSkeletonData(skeletonJson);
|
|
200
164
|
atlas.dispose(skeletonJsonReader);
|
|
201
165
|
ownsSkeletonData = true;
|
|
@@ -212,11 +176,11 @@ gworld.Skeleton = cc.Node.extend(
|
|
|
212
176
|
* @returns {cc.Rect}
|
|
213
177
|
*/
|
|
214
178
|
getBoundingBox: function () {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
for (
|
|
218
|
-
|
|
219
|
-
|
|
179
|
+
let minX = cc.FLT_MAX, minY = cc.FLT_MAX, maxX = cc.FLT_MIN, maxY = cc.FLT_MIN;
|
|
180
|
+
let scaleX = this.getScaleX(), scaleY = this.getScaleY(), vertices, slots = this._skeleton.slots, VERTEX = spine.RegionAttachment;
|
|
181
|
+
for (let i = 0, slotCount = slots.length; i < slotCount; ++i) {
|
|
182
|
+
const slot = slots[i];
|
|
183
|
+
const attachment = slot.attachment;
|
|
220
184
|
if (!attachment || !(attachment instanceof spine.RegionAttachment))
|
|
221
185
|
continue;
|
|
222
186
|
vertices = spine.Utils.setArraySize([], 8, 0);
|
|
@@ -226,7 +190,7 @@ gworld.Skeleton = cc.Node.extend(
|
|
|
226
190
|
maxX = Math.max(maxX, vertices[VERTEX.X1] * scaleX, vertices[VERTEX.X4] * scaleX, vertices[VERTEX.X2] * scaleX, vertices[VERTEX.X3] * scaleX);
|
|
227
191
|
maxY = Math.max(maxY, vertices[VERTEX.Y1] * scaleY, vertices[VERTEX.Y4] * scaleY, vertices[VERTEX.Y2] * scaleY, vertices[VERTEX.Y3] * scaleY);
|
|
228
192
|
}
|
|
229
|
-
|
|
193
|
+
const position = this.getPosition();
|
|
230
194
|
return cc.rect(position.x + minX, position.y + minY, maxX - minX, maxY - minY);
|
|
231
195
|
},
|
|
232
196
|
/**
|
|
@@ -335,9 +299,9 @@ gworld.Skeleton = cc.Node.extend(
|
|
|
335
299
|
* @returns {cc.BlendFunc}
|
|
336
300
|
*/
|
|
337
301
|
getBlendFunc: function () {
|
|
338
|
-
|
|
302
|
+
const slot = this._skeleton.drawOrder[0];
|
|
339
303
|
if (slot) {
|
|
340
|
-
|
|
304
|
+
const blend = this._renderCmd._getBlendFunc(slot.data.blendMode, this._premultipliedAlpha);
|
|
341
305
|
return blend;
|
|
342
306
|
}
|
|
343
307
|
else {
|
|
@@ -377,4 +341,4 @@ cc.defineGetterSetter(gworld.Skeleton.prototype, '_texture', function () {
|
|
|
377
341
|
gworld.Skeleton.create = function (skeletonDataFile, atlasFile /* or atlas*/, scale) {
|
|
378
342
|
return new gworld.Skeleton(skeletonDataFile, atlasFile, scale);
|
|
379
343
|
};
|
|
380
|
-
|
|
344
|
+
export const Skeleton = gworld.Skeleton;
|
|
@@ -1,42 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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.SkeletonAnimation = exports._atlasLoader = void 0;
|
|
37
|
-
var spine = __importStar(require("@esotericsoftware/spine-core"));
|
|
38
|
-
var CCSkeleton_1 = require("./CCSkeleton");
|
|
39
|
-
var CCSkeletonTexture_1 = require("./CCSkeletonTexture");
|
|
1
|
+
import * as spine from '@esotericsoftware/spine-core';
|
|
2
|
+
import { Skeleton } from './CCSkeleton';
|
|
3
|
+
import { SkeletonTexture } from './CCSkeletonTexture';
|
|
40
4
|
/****************************************************************************
|
|
41
5
|
Copyright (c) 2011-2012 cocos2d-x.org
|
|
42
6
|
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
|
@@ -63,15 +27,15 @@ var CCSkeletonTexture_1 = require("./CCSkeletonTexture");
|
|
|
63
27
|
THE SOFTWARE.
|
|
64
28
|
****************************************************************************/
|
|
65
29
|
var gworld = gworld || {};
|
|
66
|
-
|
|
30
|
+
export const _atlasLoader = {
|
|
67
31
|
spAtlasFile: null,
|
|
68
32
|
setAtlasFile: function (spAtlasFile) {
|
|
69
33
|
this.spAtlasFile = spAtlasFile;
|
|
70
34
|
},
|
|
71
35
|
load: function (line) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
36
|
+
const texturePath = cc.path.join(cc.path.dirname(this.spAtlasFile), line);
|
|
37
|
+
const texture = cc.textureCache.addImage(texturePath);
|
|
38
|
+
const tex = new SkeletonTexture({ width: texture.getPixelsWide(), height: texture.getPixelsHigh() });
|
|
75
39
|
tex.setRealTexture(texture);
|
|
76
40
|
return tex;
|
|
77
41
|
},
|
|
@@ -101,7 +65,7 @@ gworld.TrackEntryListeners = function (startListener, endListener, completeListe
|
|
|
101
65
|
this.callbackTarget = null;
|
|
102
66
|
this.skeletonNode = null;
|
|
103
67
|
};
|
|
104
|
-
|
|
68
|
+
const proto = gworld.TrackEntryListeners.prototype;
|
|
105
69
|
proto.start = function (trackEntry) {
|
|
106
70
|
if (this.startListener) {
|
|
107
71
|
this.startListener(trackEntry);
|
|
@@ -135,7 +99,7 @@ proto.dispose = function (trackEntry) {
|
|
|
135
99
|
}
|
|
136
100
|
};
|
|
137
101
|
proto.complete = function (trackEntry) {
|
|
138
|
-
|
|
102
|
+
const loopCount = Math.floor(trackEntry.trackTime / trackEntry.animationEnd);
|
|
139
103
|
if (this.completeListener) {
|
|
140
104
|
this.completeListener(trackEntry, loopCount);
|
|
141
105
|
}
|
|
@@ -165,7 +129,7 @@ gworld.TrackEntryListeners.getListeners = function (entry) {
|
|
|
165
129
|
* var spineBoy = new SkeletonAnimation('res/skeletons/spineboy.json', 'res/skeletons/spineboy.atlas');
|
|
166
130
|
* this.addChild(spineBoy, 4);
|
|
167
131
|
*/
|
|
168
|
-
|
|
132
|
+
export const SkeletonAnimation = Skeleton.extend({
|
|
169
133
|
_state: null,
|
|
170
134
|
_ownsAnimationStateData: false,
|
|
171
135
|
_listener: null,
|
|
@@ -174,7 +138,7 @@ exports.SkeletonAnimation = CCSkeleton_1.Skeleton.extend({
|
|
|
174
138
|
* @override
|
|
175
139
|
*/
|
|
176
140
|
init: function () {
|
|
177
|
-
|
|
141
|
+
Skeleton.prototype.init.call(this);
|
|
178
142
|
this._ownsAnimationStateData = true;
|
|
179
143
|
this.setAnimationStateData(new spine.AnimationStateData(this._skeleton.data));
|
|
180
144
|
},
|
|
@@ -183,7 +147,7 @@ exports.SkeletonAnimation = CCSkeleton_1.Skeleton.extend({
|
|
|
183
147
|
* @param {gworld.spine.AnimationStateData} stateData
|
|
184
148
|
*/
|
|
185
149
|
setAnimationStateData: function (stateData) {
|
|
186
|
-
|
|
150
|
+
const state = new spine.AnimationState(stateData);
|
|
187
151
|
this._listener = new gworld.TrackEntryListeners();
|
|
188
152
|
// state.rendererObject = this;
|
|
189
153
|
state.addListener(this._listener);
|
|
@@ -216,9 +180,9 @@ exports.SkeletonAnimation = CCSkeleton_1.Skeleton.extend({
|
|
|
216
180
|
* @returns {gworld.spine.TrackEntry|null}
|
|
217
181
|
*/
|
|
218
182
|
setAnimation: function (trackIndex, name, loop) {
|
|
219
|
-
|
|
183
|
+
const animation = this._skeleton.data.findAnimation(name);
|
|
220
184
|
if (!animation) {
|
|
221
|
-
cc.log(
|
|
185
|
+
cc.log(`Spine: Animation not found: ${name}`);
|
|
222
186
|
return null;
|
|
223
187
|
}
|
|
224
188
|
return this._state.setAnimationWith(trackIndex, animation, loop);
|
|
@@ -233,9 +197,9 @@ exports.SkeletonAnimation = CCSkeleton_1.Skeleton.extend({
|
|
|
233
197
|
*/
|
|
234
198
|
addAnimation: function (trackIndex, name, loop, delay) {
|
|
235
199
|
delay = delay == null ? 0 : delay;
|
|
236
|
-
|
|
200
|
+
const animation = this._skeleton.data.findAnimation(name);
|
|
237
201
|
if (!animation) {
|
|
238
|
-
cc.log(
|
|
202
|
+
cc.log(`Spine: Animation not found:${name}`);
|
|
239
203
|
return null;
|
|
240
204
|
}
|
|
241
205
|
return this._state.addAnimationWith(trackIndex, animation, loop, delay);
|
|
@@ -348,6 +312,6 @@ exports.SkeletonAnimation = CCSkeleton_1.Skeleton.extend({
|
|
|
348
312
|
* @param {Number} [scale] scale can be specified on the JSON or binary loader which will scale the bone positions, image sizes, and animation translations.
|
|
349
313
|
* @returns {gworld.Skeleton}
|
|
350
314
|
*/
|
|
351
|
-
|
|
352
|
-
return new
|
|
315
|
+
SkeletonAnimation.createWithJsonFile = SkeletonAnimation.create = function (skeletonDataFile, atlasFile /* or atlas*/, scale) {
|
|
316
|
+
return new SkeletonAnimation(skeletonDataFile, atlasFile, scale);
|
|
353
317
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare const CanvasRenderCmd: any;
|
|
2
2
|
//# sourceMappingURL=CCSkeletonCanvasRenderCmd.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CCSkeletonCanvasRenderCmd.d.ts","sourceRoot":"","sources":["../../src/spine/CCSkeletonCanvasRenderCmd.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"CCSkeletonCanvasRenderCmd.d.ts","sourceRoot":"","sources":["../../src/spine/CCSkeletonCanvasRenderCmd.ts"],"names":[],"mappings":"AA+PA,eAAO,MAAM,eAAe,KAAyB,CAAA"}
|