@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.
- package/@types/index.d.ts +61 -0
- package/@types/safex.d.ts +103 -0
- package/README.md +10 -0
- package/dist/app.d.ts +2 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/app.js +24 -0
- package/dist/dragonbones/cocos/CocosArmatureDisplay.d.ts +77 -0
- package/dist/dragonbones/cocos/CocosArmatureDisplay.d.ts.map +1 -0
- package/dist/dragonbones/cocos/CocosArmatureDisplay.js +227 -0
- package/dist/dragonbones/cocos/CocosFactory.d.ts +128 -0
- package/dist/dragonbones/cocos/CocosFactory.d.ts.map +1 -0
- package/dist/dragonbones/cocos/CocosFactory.js +231 -0
- package/dist/dragonbones/cocos/CocosSlot.d.ts +49 -0
- package/dist/dragonbones/cocos/CocosSlot.d.ts.map +1 -0
- package/dist/dragonbones/cocos/CocosSlot.js +385 -0
- package/dist/dragonbones/cocos/CocosTextureAtlasData.d.ts +53 -0
- package/dist/dragonbones/cocos/CocosTextureAtlasData.d.ts.map +1 -0
- package/dist/dragonbones/cocos/CocosTextureAtlasData.js +158 -0
- package/dist/dragonbones/dragonBones.d.ts +3 -0
- package/dist/dragonbones/dragonBones.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones.js +4788 -0
- package/dist/dragonbones/index.d.ts +20 -0
- package/dist/dragonbones/index.d.ts.map +1 -0
- package/dist/dragonbones/index.js +112 -0
- package/dist/gworld/components/AnimationComponent.d.ts +65 -0
- package/dist/gworld/components/AnimationComponent.d.ts.map +1 -0
- package/dist/gworld/components/AnimationComponent.js +141 -0
- package/dist/gworld/components/CollideComponent.d.ts +64 -0
- package/dist/gworld/components/CollideComponent.d.ts.map +1 -0
- package/dist/gworld/components/CollideComponent.js +266 -0
- package/dist/gworld/components/EnhancedComponent.d.ts +21 -0
- package/dist/gworld/components/EnhancedComponent.d.ts.map +1 -0
- package/dist/gworld/components/EnhancedComponent.js +50 -0
- package/dist/gworld/components/GUIComponent.d.ts +62 -0
- package/dist/gworld/components/GUIComponent.d.ts.map +1 -0
- package/dist/gworld/components/GUIComponent.js +158 -0
- package/dist/gworld/components/NoRenderComponent.d.ts +36 -0
- package/dist/gworld/components/NoRenderComponent.d.ts.map +1 -0
- package/dist/gworld/components/NoRenderComponent.js +74 -0
- package/dist/gworld/components/NodeComp.d.ts +184 -0
- package/dist/gworld/components/NodeComp.d.ts.map +1 -0
- package/dist/gworld/components/NodeComp.js +425 -0
- package/dist/gworld/components/RenderComponent.d.ts +53 -0
- package/dist/gworld/components/RenderComponent.d.ts.map +1 -0
- package/dist/gworld/components/RenderComponent.js +158 -0
- package/dist/gworld/core/Scene.d.ts +5 -0
- package/dist/gworld/core/Scene.d.ts.map +1 -0
- package/dist/gworld/core/Scene.js +38 -0
- package/dist/gworld/core/decorator.d.ts +9 -0
- package/dist/gworld/core/decorator.d.ts.map +1 -0
- package/dist/gworld/core/decorator.js +43 -0
- package/dist/gworld/index.d.ts +8 -0
- package/dist/gworld/index.d.ts.map +1 -0
- package/dist/gworld/index.js +43 -0
- package/dist/gworld/systems/AnimationSystem.d.ts +7 -0
- package/dist/gworld/systems/AnimationSystem.d.ts.map +1 -0
- package/dist/gworld/systems/AnimationSystem.js +38 -0
- package/dist/gworld/systems/CollideSystem.d.ts +19 -0
- package/dist/gworld/systems/CollideSystem.d.ts.map +1 -0
- package/dist/gworld/systems/CollideSystem.js +183 -0
- package/dist/gworld/systems/GUISystem.d.ts +7 -0
- package/dist/gworld/systems/GUISystem.d.ts.map +1 -0
- package/dist/gworld/systems/GUISystem.js +147 -0
- package/dist/gworld/systems/NoRenderSystem.d.ts +7 -0
- package/dist/gworld/systems/NoRenderSystem.d.ts.map +1 -0
- package/dist/gworld/systems/NoRenderSystem.js +93 -0
- package/dist/gworld/systems/RenderSystem.d.ts +15 -0
- package/dist/gworld/systems/RenderSystem.d.ts.map +1 -0
- package/dist/gworld/systems/RenderSystem.js +115 -0
- package/dist/helper/Intersection.d.ts +6 -0
- package/dist/helper/Intersection.d.ts.map +1 -0
- package/dist/helper/Intersection.js +117 -0
- package/dist/helper/NodePool.d.ts +9 -0
- package/dist/helper/NodePool.d.ts.map +1 -0
- package/dist/helper/NodePool.js +29 -0
- package/dist/helper/action.d.ts +9 -0
- package/dist/helper/action.d.ts.map +1 -0
- package/dist/helper/action.js +34 -0
- package/dist/helper/director.d.ts +3 -0
- package/dist/helper/director.d.ts.map +1 -0
- package/dist/helper/director.js +10 -0
- package/dist/helper/html-text-parser.d.ts +30 -0
- package/dist/helper/html-text-parser.d.ts.map +1 -0
- package/dist/helper/html-text-parser.js +354 -0
- package/dist/helper/math.d.ts +4 -0
- package/dist/helper/math.d.ts.map +1 -0
- package/dist/helper/math.js +9 -0
- package/dist/helper/utils.d.ts +14 -0
- package/dist/helper/utils.d.ts.map +1 -0
- package/dist/helper/utils.js +81 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +33 -0
- package/dist/polyfills.d.ts +54 -0
- package/dist/polyfills.d.ts.map +1 -0
- package/dist/polyfills.js +168 -0
- package/dist/spine/CCSkeleton.d.ts +2 -0
- package/dist/spine/CCSkeleton.d.ts.map +1 -0
- package/dist/spine/CCSkeleton.js +380 -0
- package/dist/spine/CCSkeletonAnimation.d.ts +16 -0
- package/dist/spine/CCSkeletonAnimation.d.ts.map +1 -0
- package/dist/spine/CCSkeletonAnimation.js +353 -0
- package/dist/spine/CCSkeletonCanvasRenderCmd.d.ts +2 -0
- package/dist/spine/CCSkeletonCanvasRenderCmd.d.ts.map +1 -0
- package/dist/spine/CCSkeletonCanvasRenderCmd.js +229 -0
- package/dist/spine/CCSkeletonTexture.d.ts +2 -0
- package/dist/spine/CCSkeletonTexture.d.ts.map +1 -0
- package/dist/spine/CCSkeletonTexture.js +98 -0
- package/dist/spine/CCSkeletonWebGLRenderCmd.d.ts +2 -0
- package/dist/spine/CCSkeletonWebGLRenderCmd.d.ts.map +1 -0
- package/dist/spine/CCSkeletonWebGLRenderCmd.js +317 -0
- package/package.json +32 -0
|
@@ -0,0 +1,353 @@
|
|
|
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.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");
|
|
40
|
+
/****************************************************************************
|
|
41
|
+
Copyright (c) 2011-2012 cocos2d-x.org
|
|
42
|
+
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
|
43
|
+
Copyright (c) 2014 Shengxiang Chen (Nero Chan)
|
|
44
|
+
|
|
45
|
+
http://www.cocos2d-x.org
|
|
46
|
+
|
|
47
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
48
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
49
|
+
in the Software without restriction, including without limitation the rights
|
|
50
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
51
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
52
|
+
furnished to do so, subject to the following conditions:
|
|
53
|
+
|
|
54
|
+
The above copyright notice and this permission notice shall be included in
|
|
55
|
+
all copies or substantial portions of the Software.
|
|
56
|
+
|
|
57
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
58
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
59
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
60
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
61
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
62
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
63
|
+
THE SOFTWARE.
|
|
64
|
+
****************************************************************************/
|
|
65
|
+
var gworld = gworld || {};
|
|
66
|
+
exports._atlasLoader = {
|
|
67
|
+
spAtlasFile: null,
|
|
68
|
+
setAtlasFile: function (spAtlasFile) {
|
|
69
|
+
this.spAtlasFile = spAtlasFile;
|
|
70
|
+
},
|
|
71
|
+
load: function (line) {
|
|
72
|
+
var texturePath = cc.path.join(cc.path.dirname(this.spAtlasFile), line);
|
|
73
|
+
var texture = cc.textureCache.addImage(texturePath);
|
|
74
|
+
var tex = new CCSkeletonTexture_1.SkeletonTexture({ width: texture.getPixelsWide(), height: texture.getPixelsHigh() });
|
|
75
|
+
tex.setRealTexture(texture);
|
|
76
|
+
return tex;
|
|
77
|
+
},
|
|
78
|
+
unload: function (obj) { },
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* The event type of spine skeleton animation. It contains event types: START(0), END(1), COMPLETE(2), EVENT(3).
|
|
82
|
+
* @constant
|
|
83
|
+
* @type {{START: number, END: number, COMPLETE: number, EVENT: number}}
|
|
84
|
+
*/
|
|
85
|
+
gworld.ANIMATION_EVENT_TYPE = {
|
|
86
|
+
START: 0,
|
|
87
|
+
INTERRUPT: 1,
|
|
88
|
+
END: 2,
|
|
89
|
+
DISPOSE: 3,
|
|
90
|
+
COMPLETE: 4,
|
|
91
|
+
EVENT: 5,
|
|
92
|
+
};
|
|
93
|
+
gworld.TrackEntryListeners = function (startListener, endListener, completeListener, eventListener, interruptListener, disposeListener) {
|
|
94
|
+
this.startListener = startListener || null;
|
|
95
|
+
this.endListener = endListener || null;
|
|
96
|
+
this.completeListener = completeListener || null;
|
|
97
|
+
this.eventListener = eventListener || null;
|
|
98
|
+
this.interruptListener = interruptListener || null;
|
|
99
|
+
this.disposeListener = disposeListener || null;
|
|
100
|
+
this.callback = null;
|
|
101
|
+
this.callbackTarget = null;
|
|
102
|
+
this.skeletonNode = null;
|
|
103
|
+
};
|
|
104
|
+
var proto = gworld.TrackEntryListeners.prototype;
|
|
105
|
+
proto.start = function (trackEntry) {
|
|
106
|
+
if (this.startListener) {
|
|
107
|
+
this.startListener(trackEntry);
|
|
108
|
+
}
|
|
109
|
+
if (this.callback) {
|
|
110
|
+
this.callback.call(this.callbackTarget, this.skeletonNode, trackEntry, gworld.ANIMATION_EVENT_TYPE.START, null, 0);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
proto.interrupt = function (trackEntry) {
|
|
114
|
+
if (this.interruptListener) {
|
|
115
|
+
this.interruptListener(trackEntry);
|
|
116
|
+
}
|
|
117
|
+
if (this.callback) {
|
|
118
|
+
this.callback.call(this.callbackTarget, this.skeletonNode, trackEntry, gworld.ANIMATION_EVENT_TYPE.INTERRUPT, null, 0);
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
proto.end = function (trackEntry) {
|
|
122
|
+
if (this.endListener) {
|
|
123
|
+
this.endListener(trackEntry);
|
|
124
|
+
}
|
|
125
|
+
if (this.callback) {
|
|
126
|
+
this.callback.call(this.callbackTarget, this.skeletonNode, trackEntry, gworld.ANIMATION_EVENT_TYPE.END, null, 0);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
proto.dispose = function (trackEntry) {
|
|
130
|
+
if (this.disposeListener) {
|
|
131
|
+
this.disposeListener(trackEntry);
|
|
132
|
+
}
|
|
133
|
+
if (this.callback) {
|
|
134
|
+
this.callback.call(this.callbackTarget, this.skeletonNode, trackEntry, gworld.ANIMATION_EVENT_TYPE.DISPOSE, null, 0);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
proto.complete = function (trackEntry) {
|
|
138
|
+
var loopCount = Math.floor(trackEntry.trackTime / trackEntry.animationEnd);
|
|
139
|
+
if (this.completeListener) {
|
|
140
|
+
this.completeListener(trackEntry, loopCount);
|
|
141
|
+
}
|
|
142
|
+
if (this.callback) {
|
|
143
|
+
this.callback.call(this.callbackTarget, this.skeletonNode, trackEntry, gworld.ANIMATION_EVENT_TYPE.COMPLETE, null, loopCount);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
proto.event = function (trackEntry, event) {
|
|
147
|
+
if (this.eventListener) {
|
|
148
|
+
this.eventListener(trackEntry, event);
|
|
149
|
+
}
|
|
150
|
+
if (this.callback) {
|
|
151
|
+
this.callback.call(this.callbackTarget, this.skeletonNode, trackEntry, gworld.ANIMATION_EVENT_TYPE.EVENT, event, 0);
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
gworld.TrackEntryListeners.getListeners = function (entry) {
|
|
155
|
+
if (!entry.listener) {
|
|
156
|
+
entry.listener = new gworld.TrackEntryListeners();
|
|
157
|
+
}
|
|
158
|
+
return entry.listener;
|
|
159
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* The skeleton animation of spine. It updates animation's state and skeleton's world transform.
|
|
162
|
+
* @class
|
|
163
|
+
* @extends gworld.Skeleton
|
|
164
|
+
* @example
|
|
165
|
+
* var spineBoy = new SkeletonAnimation('res/skeletons/spineboy.json', 'res/skeletons/spineboy.atlas');
|
|
166
|
+
* this.addChild(spineBoy, 4);
|
|
167
|
+
*/
|
|
168
|
+
exports.SkeletonAnimation = CCSkeleton_1.Skeleton.extend({
|
|
169
|
+
_state: null,
|
|
170
|
+
_ownsAnimationStateData: false,
|
|
171
|
+
_listener: null,
|
|
172
|
+
/**
|
|
173
|
+
* Initializes a SkeletonAnimation. please do not call this function by yourself, you should pass the parameters to constructor to initialize it.
|
|
174
|
+
* @override
|
|
175
|
+
*/
|
|
176
|
+
init: function () {
|
|
177
|
+
CCSkeleton_1.Skeleton.prototype.init.call(this);
|
|
178
|
+
this._ownsAnimationStateData = true;
|
|
179
|
+
this.setAnimationStateData(new spine.AnimationStateData(this._skeleton.data));
|
|
180
|
+
},
|
|
181
|
+
/**
|
|
182
|
+
* Sets animation state data to SkeletonAnimation.
|
|
183
|
+
* @param {gworld.spine.AnimationStateData} stateData
|
|
184
|
+
*/
|
|
185
|
+
setAnimationStateData: function (stateData) {
|
|
186
|
+
var state = new spine.AnimationState(stateData);
|
|
187
|
+
this._listener = new gworld.TrackEntryListeners();
|
|
188
|
+
// state.rendererObject = this;
|
|
189
|
+
state.addListener(this._listener);
|
|
190
|
+
this._state = state;
|
|
191
|
+
},
|
|
192
|
+
/**
|
|
193
|
+
* Mix applies all keyframe values, interpolated for the specified time and mixed with the current values. <br/>
|
|
194
|
+
* @param {String} fromAnimation
|
|
195
|
+
* @param {String} toAnimation
|
|
196
|
+
* @param {Number} duration
|
|
197
|
+
*/
|
|
198
|
+
setMix: function (fromAnimation, toAnimation, duration) {
|
|
199
|
+
this._state.data.setMixWith(fromAnimation, toAnimation, duration);
|
|
200
|
+
},
|
|
201
|
+
/**
|
|
202
|
+
* Sets event listener of SkeletonAnimation.
|
|
203
|
+
* @param {Object} target
|
|
204
|
+
* @param {Function} callback
|
|
205
|
+
*/
|
|
206
|
+
setAnimationListener: function (target, callback) {
|
|
207
|
+
this._listener.callbackTarget = target;
|
|
208
|
+
this._listener.callback = callback;
|
|
209
|
+
this._listener.skeletonNode = this;
|
|
210
|
+
},
|
|
211
|
+
/**
|
|
212
|
+
* Set the current animation. Any queued animations are cleared.
|
|
213
|
+
* @param {Number} trackIndex
|
|
214
|
+
* @param {String} name
|
|
215
|
+
* @param {Boolean} loop
|
|
216
|
+
* @returns {gworld.spine.TrackEntry|null}
|
|
217
|
+
*/
|
|
218
|
+
setAnimation: function (trackIndex, name, loop) {
|
|
219
|
+
var animation = this._skeleton.data.findAnimation(name);
|
|
220
|
+
if (!animation) {
|
|
221
|
+
cc.log("Spine: Animation not found: ".concat(name));
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
224
|
+
return this._state.setAnimationWith(trackIndex, animation, loop);
|
|
225
|
+
},
|
|
226
|
+
/**
|
|
227
|
+
* Adds an animation to be played delay seconds after the current or last queued animation.
|
|
228
|
+
* @param {Number} trackIndex
|
|
229
|
+
* @param {String} name
|
|
230
|
+
* @param {Boolean} loop
|
|
231
|
+
* @param {Number} [delay=0]
|
|
232
|
+
* @returns {gworld.spine.TrackEntry|null}
|
|
233
|
+
*/
|
|
234
|
+
addAnimation: function (trackIndex, name, loop, delay) {
|
|
235
|
+
delay = delay == null ? 0 : delay;
|
|
236
|
+
var animation = this._skeleton.data.findAnimation(name);
|
|
237
|
+
if (!animation) {
|
|
238
|
+
cc.log("Spine: Animation not found:".concat(name));
|
|
239
|
+
return null;
|
|
240
|
+
}
|
|
241
|
+
return this._state.addAnimationWith(trackIndex, animation, loop, delay);
|
|
242
|
+
},
|
|
243
|
+
/**
|
|
244
|
+
* Find animation with specified name
|
|
245
|
+
* @param {String} name
|
|
246
|
+
* @returns {gworld.spine.Animation|null}
|
|
247
|
+
*/
|
|
248
|
+
findAnimation: function (name) {
|
|
249
|
+
return this._skeleton.data.findAnimation(name);
|
|
250
|
+
},
|
|
251
|
+
/**
|
|
252
|
+
* Returns track entry by trackIndex.
|
|
253
|
+
* @param trackIndex
|
|
254
|
+
* @returns {gworld.spine.TrackEntry|null}
|
|
255
|
+
*/
|
|
256
|
+
getCurrent: function (trackIndex) {
|
|
257
|
+
return this._state.getCurrent(trackIndex);
|
|
258
|
+
},
|
|
259
|
+
/**
|
|
260
|
+
* Clears all tracks of animation state.
|
|
261
|
+
*/
|
|
262
|
+
clearTracks: function () {
|
|
263
|
+
this._state.clearTracks();
|
|
264
|
+
},
|
|
265
|
+
/**
|
|
266
|
+
* Clears track of animation state by trackIndex.
|
|
267
|
+
* @param {Number} trackIndex
|
|
268
|
+
*/
|
|
269
|
+
clearTrack: function (trackIndex) {
|
|
270
|
+
this._state.clearTrack(trackIndex);
|
|
271
|
+
},
|
|
272
|
+
/**
|
|
273
|
+
* Update will be called automatically every frame if "scheduleUpdate" is called when the node is "live".
|
|
274
|
+
* It updates animation's state and skeleton's world transform.
|
|
275
|
+
* @param {Number} dt Delta time since last update
|
|
276
|
+
* @override
|
|
277
|
+
*/
|
|
278
|
+
update: function (dt) {
|
|
279
|
+
this._super(dt);
|
|
280
|
+
dt *= this._timeScale;
|
|
281
|
+
this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.contentDirty);
|
|
282
|
+
this._state.update(dt);
|
|
283
|
+
this._state.apply(this._skeleton);
|
|
284
|
+
this._skeleton.updateWorldTransform(true);
|
|
285
|
+
this._renderCmd._updateChild();
|
|
286
|
+
},
|
|
287
|
+
/**
|
|
288
|
+
* Set the start event listener.
|
|
289
|
+
* @param {function} listener
|
|
290
|
+
*/
|
|
291
|
+
setStartListener: function (listener) {
|
|
292
|
+
this._listener.startListener = listener;
|
|
293
|
+
},
|
|
294
|
+
/**
|
|
295
|
+
* Set the interrupt listener
|
|
296
|
+
* @param {function} listener
|
|
297
|
+
*/
|
|
298
|
+
setInterruptListener: function (listener) {
|
|
299
|
+
this._listener.interruptListener = listener;
|
|
300
|
+
},
|
|
301
|
+
/**
|
|
302
|
+
* Set the end event listener.
|
|
303
|
+
* @param {function} listener
|
|
304
|
+
*/
|
|
305
|
+
setEndListener: function (listener) {
|
|
306
|
+
this._listener.endListener = listener;
|
|
307
|
+
},
|
|
308
|
+
/**
|
|
309
|
+
* Set the dispose listener
|
|
310
|
+
* @param {function} listener
|
|
311
|
+
*/
|
|
312
|
+
setDisposeListener: function (listener) {
|
|
313
|
+
this._listener.disposeListener = listener;
|
|
314
|
+
},
|
|
315
|
+
setCompleteListener: function (listener) {
|
|
316
|
+
this._listener.completeListener = listener;
|
|
317
|
+
},
|
|
318
|
+
setEventListener: function (listener) {
|
|
319
|
+
this._listener.eventListener = listener;
|
|
320
|
+
},
|
|
321
|
+
setTrackStartListener: function (entry, listener) {
|
|
322
|
+
gworld.TrackEntryListeners.getListeners(entry).startListener = listener;
|
|
323
|
+
},
|
|
324
|
+
setTrackInterruptListener: function (entry, listener) {
|
|
325
|
+
gworld.TrackEntryListeners.getListeners(entry).interruptListener = listener;
|
|
326
|
+
},
|
|
327
|
+
setTrackEndListener: function (entry, listener) {
|
|
328
|
+
gworld.TrackEntryListeners.getListeners(entry).endListener = listener;
|
|
329
|
+
},
|
|
330
|
+
setTrackDisposeListener: function (entry, listener) {
|
|
331
|
+
gworld.TrackEntryListeners.getListeners(entry).disposeListener = listener;
|
|
332
|
+
},
|
|
333
|
+
setTrackCompleteListener: function (entry, listener) {
|
|
334
|
+
gworld.TrackEntryListeners.getListeners(entry).completeListener = listener;
|
|
335
|
+
},
|
|
336
|
+
setTrackEventListener: function (entry, listener) {
|
|
337
|
+
gworld.TrackEntryListeners.getListeners(entry).eventListener = listener;
|
|
338
|
+
},
|
|
339
|
+
getState: function () {
|
|
340
|
+
return this._state;
|
|
341
|
+
},
|
|
342
|
+
});
|
|
343
|
+
/**
|
|
344
|
+
* Creates a skeleton animation object.
|
|
345
|
+
* @deprecated since v3.0, please use new SkeletonAnimation(skeletonDataFile, atlasFile, scale) instead.
|
|
346
|
+
* @param {spine.SkeletonData|String} skeletonDataFile
|
|
347
|
+
* @param {String|spine.Atlas|spine.SkeletonData} atlasFile atlas filename or atlas data or owns SkeletonData
|
|
348
|
+
* @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
|
+
* @returns {gworld.Skeleton}
|
|
350
|
+
*/
|
|
351
|
+
exports.SkeletonAnimation.createWithJsonFile = exports.SkeletonAnimation.create = function (skeletonDataFile, atlasFile /* or atlas*/, scale) {
|
|
352
|
+
return new exports.SkeletonAnimation(skeletonDataFile, atlasFile, scale);
|
|
353
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CCSkeletonCanvasRenderCmd.d.ts","sourceRoot":"","sources":["../../src/spine/CCSkeletonCanvasRenderCmd.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var spine_core_1 = __importDefault(require("@esotericsoftware/spine-core"));
|
|
7
|
+
/****************************************************************************
|
|
8
|
+
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
|
9
|
+
|
|
10
|
+
http://www.cocos2d-x.org
|
|
11
|
+
|
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
in the Software without restriction, including without limitation the rights
|
|
15
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
furnished to do so, subject to the following conditions:
|
|
18
|
+
|
|
19
|
+
The above copyright notice and this permission notice shall be included in
|
|
20
|
+
all copies or substantial portions of the Software.
|
|
21
|
+
|
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
28
|
+
THE SOFTWARE.
|
|
29
|
+
****************************************************************************/
|
|
30
|
+
var gworld = gworld || {};
|
|
31
|
+
(function () {
|
|
32
|
+
gworld.Skeleton.CanvasRenderCmd = function (renderableObject) {
|
|
33
|
+
this._rootCtor(renderableObject);
|
|
34
|
+
this._needDraw = true;
|
|
35
|
+
};
|
|
36
|
+
var proto = (gworld.Skeleton.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype));
|
|
37
|
+
proto.constructor = gworld.Skeleton.CanvasRenderCmd;
|
|
38
|
+
proto.rendering = function (wrapper, scaleX, scaleY) {
|
|
39
|
+
var node = this._node, i, n, slot, slotNode;
|
|
40
|
+
wrapper = wrapper || cc._renderContext;
|
|
41
|
+
var locSkeleton = node._skeleton, drawOrder = locSkeleton.drawOrder;
|
|
42
|
+
for (i = 0, n = drawOrder.length; i < n; i++) {
|
|
43
|
+
slot = drawOrder[i];
|
|
44
|
+
slotNode = slot._slotNode;
|
|
45
|
+
if (slotNode._visible && slotNode._renderCmd && slot.currentSprite) {
|
|
46
|
+
slotNode._renderCmd.transform(this, true);
|
|
47
|
+
slot.currentSprite._renderCmd.rendering(wrapper, scaleX, scaleY);
|
|
48
|
+
slotNode._renderCmd._dirtyFlag = slot.currentSprite._renderCmd._dirtyFlag = 0;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (!node._debugSlots && !node._debugBones)
|
|
52
|
+
return;
|
|
53
|
+
wrapper.setTransform(this._worldTransform, scaleX, scaleY);
|
|
54
|
+
wrapper.setGlobalAlpha(1);
|
|
55
|
+
var attachment, drawingUtil = cc._drawingUtil;
|
|
56
|
+
if (node._debugSlots) {
|
|
57
|
+
// Slots.
|
|
58
|
+
drawingUtil.setDrawColor(0, 0, 255, 255);
|
|
59
|
+
drawingUtil.setLineWidth(1);
|
|
60
|
+
var points = [];
|
|
61
|
+
for (i = 0, n = locSkeleton.slots.length; i < n; i++) {
|
|
62
|
+
slot = locSkeleton.drawOrder[i];
|
|
63
|
+
if (!slot.attachment || !(slot.attachment instanceof spine_core_1.default.RegionAttachment))
|
|
64
|
+
continue;
|
|
65
|
+
attachment = slot.attachment;
|
|
66
|
+
this._updateRegionAttachmentSlot(attachment, slot, points);
|
|
67
|
+
drawingUtil.drawPoly(points, 4, true);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (node._debugBones) {
|
|
71
|
+
// Bone lengths.
|
|
72
|
+
var bone = void 0;
|
|
73
|
+
drawingUtil.setLineWidth(2);
|
|
74
|
+
drawingUtil.setDrawColor(255, 0, 0, 255);
|
|
75
|
+
for (i = 0, n = locSkeleton.bones.length; i < n; i++) {
|
|
76
|
+
bone = locSkeleton.bones[i];
|
|
77
|
+
var x = bone.data.length * bone.a + bone.worldX;
|
|
78
|
+
var y = bone.data.length * bone.c + bone.worldY;
|
|
79
|
+
drawingUtil.drawLine({ x: bone.worldX, y: bone.worldY }, { x: x, y: y });
|
|
80
|
+
}
|
|
81
|
+
// Bone origins.
|
|
82
|
+
var pointSize = 4;
|
|
83
|
+
drawingUtil.setDrawColor(0, 0, 255, 255); // Root bone is blue.
|
|
84
|
+
for (i = 0, n = locSkeleton.bones.length; i < n; i++) {
|
|
85
|
+
bone = locSkeleton.bones[i];
|
|
86
|
+
drawingUtil.drawPoint({ x: bone.worldX, y: bone.worldY }, pointSize);
|
|
87
|
+
if (i === 0)
|
|
88
|
+
drawingUtil.setDrawColor(0, 255, 0, 255);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
proto.updateStatus = function () {
|
|
93
|
+
this.originUpdateStatus();
|
|
94
|
+
this._updateCurrentRegions();
|
|
95
|
+
this._regionFlag = cc.Node.CanvasRenderCmd.RegionStatus.DirtyDouble;
|
|
96
|
+
this._dirtyFlag &= ~cc.Node._dirtyFlags.contentDirty;
|
|
97
|
+
};
|
|
98
|
+
proto.getLocalBB = function () {
|
|
99
|
+
return this._node.getBoundingBox();
|
|
100
|
+
};
|
|
101
|
+
proto._updateRegionAttachmentSlot = function (attachment, slot, points) {
|
|
102
|
+
if (!points)
|
|
103
|
+
return;
|
|
104
|
+
var vertices = spine_core_1.default.Utils.setArraySize([], 8, 0);
|
|
105
|
+
attachment.computeWorldVertices(slot, vertices, 0, 2);
|
|
106
|
+
var VERTEX = spine_core_1.default.RegionAttachment;
|
|
107
|
+
points.length = 0;
|
|
108
|
+
points.push(cc.p(vertices[VERTEX.X1], vertices[VERTEX.Y1]));
|
|
109
|
+
points.push(cc.p(vertices[VERTEX.X4], vertices[VERTEX.Y4]));
|
|
110
|
+
points.push(cc.p(vertices[VERTEX.X3], vertices[VERTEX.Y3]));
|
|
111
|
+
points.push(cc.p(vertices[VERTEX.X2], vertices[VERTEX.Y2]));
|
|
112
|
+
};
|
|
113
|
+
proto._createChildFormSkeletonData = function () {
|
|
114
|
+
var node = this._node;
|
|
115
|
+
var locSkeleton = node._skeleton, spriteName, sprite;
|
|
116
|
+
for (var i = 0, n = locSkeleton.slots.length; i < n; i++) {
|
|
117
|
+
var slot = locSkeleton.slots[i], attachment = slot.attachment;
|
|
118
|
+
var slotNode = new cc.Node();
|
|
119
|
+
slot._slotNode = slotNode;
|
|
120
|
+
if (attachment instanceof spine_core_1.default.RegionAttachment) {
|
|
121
|
+
spriteName = attachment.name;
|
|
122
|
+
sprite = this._createSprite(slot, attachment);
|
|
123
|
+
slot.currentSprite = sprite;
|
|
124
|
+
slot.currentSpriteName = spriteName;
|
|
125
|
+
slotNode.addChild(sprite);
|
|
126
|
+
}
|
|
127
|
+
else if (attachment instanceof spine_core_1.default.MeshAttachment) {
|
|
128
|
+
//todo for mesh
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
var loaded = function (sprite, texture, attachment) {
|
|
133
|
+
var rendererObject = attachment.region;
|
|
134
|
+
var rect = new cc.Rect(rendererObject.x, rendererObject.y, rendererObject.width, rendererObject.height);
|
|
135
|
+
sprite.initWithTexture(texture, rect, rendererObject.rotate, false);
|
|
136
|
+
sprite._rect.width = attachment.width;
|
|
137
|
+
sprite._rect.height = attachment.height;
|
|
138
|
+
sprite.setContentSize(attachment.width, attachment.height);
|
|
139
|
+
sprite.setRotation(-attachment.rotation);
|
|
140
|
+
sprite.setScale((rendererObject.width / rendererObject.originalWidth) * attachment.scaleX, (rendererObject.height / rendererObject.originalHeight) * attachment.scaleY);
|
|
141
|
+
};
|
|
142
|
+
proto._createSprite = function (slot, attachment) {
|
|
143
|
+
var rendererObject = attachment.region;
|
|
144
|
+
var texture = rendererObject.texture.getRealTexture();
|
|
145
|
+
var sprite = new cc.Sprite();
|
|
146
|
+
if (texture.isLoaded()) {
|
|
147
|
+
loaded(sprite, texture, attachment);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
texture.addEventListener('load', function () {
|
|
151
|
+
loaded(sprite, texture, attachment);
|
|
152
|
+
}, this);
|
|
153
|
+
}
|
|
154
|
+
slot.sprites = slot.sprites || {};
|
|
155
|
+
slot.sprites[rendererObject.name] = sprite;
|
|
156
|
+
return sprite;
|
|
157
|
+
};
|
|
158
|
+
proto._updateChild = function () {
|
|
159
|
+
var locSkeleton = this._node._skeleton, slots = locSkeleton.slots;
|
|
160
|
+
var color = this._displayedColor, opacity = this._displayedOpacity;
|
|
161
|
+
var i, n, selSprite, ax, ay;
|
|
162
|
+
var slot, attachment, slotNode;
|
|
163
|
+
for (i = 0, n = slots.length; i < n; i++) {
|
|
164
|
+
slot = slots[i];
|
|
165
|
+
attachment = slot.attachment;
|
|
166
|
+
slotNode = slot._slotNode;
|
|
167
|
+
if (!attachment) {
|
|
168
|
+
slotNode.setVisible(false);
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
if (attachment instanceof spine_core_1.default.RegionAttachment) {
|
|
172
|
+
if (attachment.region) {
|
|
173
|
+
if (!slot.currentSpriteName || slot.currentSpriteName !== attachment.name) {
|
|
174
|
+
var spriteName = attachment.name;
|
|
175
|
+
if (slot.currentSprite !== undefined)
|
|
176
|
+
slot.currentSprite.setVisible(false);
|
|
177
|
+
slot.sprites = slot.sprites || {};
|
|
178
|
+
if (slot.sprites[spriteName] !== undefined)
|
|
179
|
+
slot.sprites[spriteName].setVisible(true);
|
|
180
|
+
else {
|
|
181
|
+
var sprite = this._createSprite(slot, attachment);
|
|
182
|
+
slotNode.addChild(sprite);
|
|
183
|
+
}
|
|
184
|
+
slot.currentSprite = slot.sprites[spriteName];
|
|
185
|
+
slot.currentSpriteName = spriteName;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
var bone = slot.bone;
|
|
189
|
+
if (attachment.region.offsetX === 0 && attachment.region.offsetY === 0) {
|
|
190
|
+
ax = attachment.x;
|
|
191
|
+
ay = attachment.y;
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
//var regionScaleX = attachment.width / attachment.regionOriginalWidth * attachment.scaleX;
|
|
195
|
+
//ax = attachment.x + attachment.regionOffsetX * regionScaleX - (attachment.width * attachment.scaleX - attachment.regionWidth * regionScaleX) / 2;
|
|
196
|
+
ax = (attachment.offset[0] + attachment.offset[4]) * 0.5;
|
|
197
|
+
ay = (attachment.offset[1] + attachment.offset[5]) * 0.5;
|
|
198
|
+
}
|
|
199
|
+
slotNode.setPosition(bone.worldX + ax * bone.a + ay * bone.b, bone.worldY + ax * bone.c + ay * bone.d);
|
|
200
|
+
slotNode.setScale(bone.getWorldScaleX(), bone.getWorldScaleY());
|
|
201
|
+
//set the color and opacity
|
|
202
|
+
selSprite = slot.currentSprite;
|
|
203
|
+
selSprite._flippedX = bone.skeleton.flipX;
|
|
204
|
+
selSprite._flippedY = bone.skeleton.flipY;
|
|
205
|
+
if (selSprite._flippedY || selSprite._flippedX) {
|
|
206
|
+
slotNode.setRotation(bone.getWorldRotationX());
|
|
207
|
+
selSprite.setRotation(attachment.rotation);
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
slotNode.setRotation(-bone.getWorldRotationX());
|
|
211
|
+
selSprite.setRotation(-attachment.rotation);
|
|
212
|
+
}
|
|
213
|
+
//hack for sprite
|
|
214
|
+
selSprite._renderCmd._displayedOpacity = 0 | (opacity * slot.color.a);
|
|
215
|
+
var r = 0 | (color.r * slot.color.r), g = 0 | (color.g * slot.color.g), b = 0 | (color.b * slot.color.b);
|
|
216
|
+
selSprite.setColor(cc.color(r, g, b));
|
|
217
|
+
selSprite._renderCmd._updateColor();
|
|
218
|
+
}
|
|
219
|
+
else if (attachment instanceof spine_core_1.default.MeshAttachment) {
|
|
220
|
+
// Can not render mesh
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
slotNode.setVisible(false);
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
slotNode.setVisible(true);
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CCSkeletonTexture.d.ts","sourceRoot":"","sources":["../../src/spine/CCSkeletonTexture.ts"],"names":[],"mappings":"AAoEA,eAAO,MAAM,eAAe,KAAyB,CAAA"}
|