@safe-engine/cocos 2.2.8 → 2.3.4

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 (104) hide show
  1. package/@types/index.d.ts +0 -59
  2. package/dist/app.d.ts +1 -1
  3. package/dist/app.d.ts.map +1 -1
  4. package/dist/app.js +25 -23
  5. package/dist/collider/CollideComponent.d.ts +21 -3
  6. package/dist/collider/CollideComponent.d.ts.map +1 -1
  7. package/dist/core/NodeComp.d.ts +1 -1
  8. package/dist/core/NodeComp.d.ts.map +1 -1
  9. package/dist/dragonbones/DragonBonesComp.d.ts +4 -6
  10. package/dist/dragonbones/DragonBonesComp.d.ts.map +1 -1
  11. package/dist/dragonbones/DragonBonesComp.js +15 -13
  12. package/dist/dragonbones/DragonBonesSystem.d.ts +1 -1
  13. package/dist/dragonbones/DragonBonesSystem.d.ts.map +1 -1
  14. package/dist/dragonbones/DragonBonesSystem.js +42 -35
  15. package/dist/dragonbones/db-cocos/CocosArmatureDisplay.d.ts +87 -0
  16. package/dist/dragonbones/db-cocos/CocosArmatureDisplay.d.ts.map +1 -0
  17. package/dist/dragonbones/db-cocos/CocosArmatureDisplay.js +240 -0
  18. package/dist/dragonbones/db-cocos/CocosFactory.d.ts +128 -0
  19. package/dist/dragonbones/db-cocos/CocosFactory.d.ts.map +1 -0
  20. package/dist/dragonbones/db-cocos/CocosFactory.js +190 -0
  21. package/dist/dragonbones/db-cocos/CocosSlot.d.ts +49 -0
  22. package/dist/dragonbones/db-cocos/CocosSlot.d.ts.map +1 -0
  23. package/dist/dragonbones/db-cocos/CocosSlot.js +368 -0
  24. package/dist/dragonbones/db-cocos/CocosTextureAtlasData.d.ts +53 -0
  25. package/dist/dragonbones/db-cocos/CocosTextureAtlasData.d.ts.map +1 -0
  26. package/dist/dragonbones/db-cocos/CocosTextureAtlasData.js +121 -0
  27. package/dist/dragonbones/index.d.ts +0 -1
  28. package/dist/dragonbones/index.d.ts.map +1 -1
  29. package/dist/dragonbones/index.js +0 -1
  30. package/dist/polyfills.d.ts +1 -1
  31. package/dist/polyfills.d.ts.map +1 -1
  32. package/dist/polyfills.js +1 -2
  33. package/dist/render/RenderComponent.d.ts.map +1 -1
  34. package/dist/render/RenderComponent.js +1 -0
  35. package/dist/render/RenderSystem.d.ts.map +1 -1
  36. package/dist/render/RenderSystem.js +34 -2
  37. package/dist/richtext/RichTextComp.js +1 -1
  38. package/dist/spine/SpineSkeleton.d.ts +5 -3
  39. package/dist/spine/SpineSkeleton.d.ts.map +1 -1
  40. package/dist/spine/SpineSkeleton.js +12 -5
  41. package/dist/spine/SpineSystem.d.ts +1 -2
  42. package/dist/spine/SpineSystem.d.ts.map +1 -1
  43. package/dist/spine/SpineSystem.js +22 -24
  44. package/dist/spine/index.d.ts +0 -1
  45. package/dist/spine/index.d.ts.map +1 -1
  46. package/dist/spine/index.js +14 -2
  47. package/dist/spine/spine-cocos/CCSkeleton.d.ts +86 -0
  48. package/dist/spine/spine-cocos/CCSkeleton.d.ts.map +1 -0
  49. package/dist/spine/{CCSkeleton.js → spine-cocos/CCSkeleton.js} +39 -128
  50. package/dist/spine/spine-cocos/CCSkeletonAnimation.d.ts +87 -0
  51. package/dist/spine/spine-cocos/CCSkeletonAnimation.d.ts.map +1 -0
  52. package/dist/spine/{CCSkeletonAnimation.js → spine-cocos/CCSkeletonAnimation.js} +37 -97
  53. package/dist/spine/spine-cocos/CCSkeletonCanvasRenderCmd.d.ts +28 -0
  54. package/dist/spine/spine-cocos/CCSkeletonCanvasRenderCmd.d.ts.map +1 -0
  55. package/dist/spine/spine-cocos/CCSkeletonCanvasRenderCmd.js +224 -0
  56. package/dist/spine/{CCSkeletonTexture.d.ts → spine-cocos/CCSkeletonTexture.d.ts} +1 -1
  57. package/dist/spine/spine-cocos/CCSkeletonTexture.d.ts.map +1 -0
  58. package/dist/spine/{CCSkeletonTexture.js → spine-cocos/CCSkeletonTexture.js} +5 -5
  59. package/dist/spine/spine-cocos/CCSkeletonWebGLRenderCmd.d.ts.map +1 -0
  60. package/dist/spine/{CCSkeletonWebGLRenderCmd.js → spine-cocos/CCSkeletonWebGLRenderCmd.js} +13 -13
  61. package/package.json +5 -6
  62. package/dist/core/index.d.ts +0 -6
  63. package/dist/core/index.d.ts.map +0 -1
  64. package/dist/core/index.js +0 -5
  65. package/dist/dragonbones/PixiDragonBonesSprite.d.ts +0 -19
  66. package/dist/dragonbones/PixiDragonBonesSprite.d.ts.map +0 -1
  67. package/dist/dragonbones/PixiDragonBonesSprite.js +0 -75
  68. package/dist/gworld/EnhancedComponent.d.ts +0 -22
  69. package/dist/gworld/EnhancedComponent.d.ts.map +0 -1
  70. package/dist/gworld/EnhancedComponent.js +0 -44
  71. package/dist/gworld/NodeComp.d.ts +0 -153
  72. package/dist/gworld/NodeComp.d.ts.map +0 -1
  73. package/dist/gworld/NodeComp.js +0 -337
  74. package/dist/gworld/NodePool.d.ts +0 -9
  75. package/dist/gworld/NodePool.d.ts.map +0 -1
  76. package/dist/gworld/NodePool.js +0 -23
  77. package/dist/gworld/Scene.d.ts +0 -5
  78. package/dist/gworld/Scene.d.ts.map +0 -1
  79. package/dist/gworld/Scene.js +0 -14
  80. package/dist/gworld/decorator.d.ts +0 -8
  81. package/dist/gworld/decorator.d.ts.map +0 -1
  82. package/dist/gworld/decorator.js +0 -12
  83. package/dist/gworld/index.d.ts +0 -8
  84. package/dist/gworld/index.d.ts.map +0 -1
  85. package/dist/gworld/index.js +0 -14
  86. package/dist/render/TiledSprite.d.ts +0 -13
  87. package/dist/render/TiledSprite.d.ts.map +0 -1
  88. package/dist/render/TiledSprite.js +0 -69
  89. package/dist/safex.d.ts +0 -10
  90. package/dist/safex.d.ts.map +0 -1
  91. package/dist/safex.js +0 -1
  92. package/dist/spine/CCSkeleton.d.ts +0 -189
  93. package/dist/spine/CCSkeleton.d.ts.map +0 -1
  94. package/dist/spine/CCSkeletonAnimation.d.ts +0 -146
  95. package/dist/spine/CCSkeletonAnimation.d.ts.map +0 -1
  96. package/dist/spine/CCSkeletonCanvasRenderCmd.d.ts +0 -2
  97. package/dist/spine/CCSkeletonCanvasRenderCmd.d.ts.map +0 -1
  98. package/dist/spine/CCSkeletonCanvasRenderCmd.js +0 -228
  99. package/dist/spine/CCSkeletonTexture.d.ts.map +0 -1
  100. package/dist/spine/CCSkeletonWebGLRenderCmd.d.ts.map +0 -1
  101. package/dist/spine/PixiSpineSprite.d.ts +0 -19
  102. package/dist/spine/PixiSpineSprite.d.ts.map +0 -1
  103. package/dist/spine/PixiSpineSprite.js +0 -72
  104. /package/dist/spine/{CCSkeletonWebGLRenderCmd.d.ts → spine-cocos/CCSkeletonWebGLRenderCmd.d.ts} +0 -0
@@ -0,0 +1,87 @@
1
+ import { Animation, AnimationState, AnimationStateData } from '@esotericsoftware/spine-core';
2
+ import { CCSkeleton } from './CCSkeleton';
3
+ /****************************************************************************
4
+ Copyright (c) 2011-2012 cocos2d-x.org
5
+ Copyright (c) 2013-2014 Chukong Technologies Inc.
6
+ Copyright (c) 2014 Shengxiang Chen (Nero Chan)
7
+
8
+ http://www.cocos2d-x.org
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in
18
+ all copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26
+ THE SOFTWARE.
27
+ ****************************************************************************/
28
+ export declare const _atlasLoader: {
29
+ spAtlasFile: any;
30
+ setAtlasFile: (spAtlasFile: any) => void;
31
+ load: (line: any) => any;
32
+ unload: () => void;
33
+ };
34
+ /**
35
+ * The event type of spine skeleton animation. It contains event types: START(0), END(1), COMPLETE(2), EVENT(3).
36
+ * @constant
37
+ * @type {{START: number, END: number, COMPLETE: number, EVENT: number}}
38
+ */
39
+ export declare const ANIMATION_EVENT_TYPE: {
40
+ START: number;
41
+ INTERRUPT: number;
42
+ END: number;
43
+ DISPOSE: number;
44
+ COMPLETE: number;
45
+ EVENT: number;
46
+ };
47
+ export declare const TrackEntryListeners: {
48
+ (startListener?: any, endListener?: any, completeListener?: any, eventListener?: any, interruptListener?: any, disposeListener?: any): void;
49
+ getListeners(entry: any): any;
50
+ };
51
+ /**
52
+ * The skeleton animation of It updates animation's state and skeleton's world transform.
53
+ * @class
54
+ * @extends Skeleton
55
+ * @example
56
+ * var spineBoy = new SkeletonAnimation('res/skeletons/spineboy.json', 'res/skeletons/spineboy.atlas');
57
+ * this.addChild(spineBoy, 4);
58
+ */
59
+ export declare class SkeletonAnimation extends CCSkeleton {
60
+ init(): boolean;
61
+ setAnimationStateData(stateData: AnimationStateData): void;
62
+ setMix(fromAnimation: Animation, toAnimation: Animation, duration: number): void;
63
+ setAnimationListener(target: any, callback: Function): void;
64
+ setAnimation(trackIndex: number, name: string, loop: boolean): import("@esotericsoftware/spine-core").TrackEntry;
65
+ addAnimation(trackIndex: number, name: string, loop: boolean, delay?: number): import("@esotericsoftware/spine-core").TrackEntry;
66
+ findAnimation(name: string): Animation;
67
+ getCurrent(trackIndex: number): import("@esotericsoftware/spine-core").TrackEntry;
68
+ clearTracks(): void;
69
+ clearTrack(trackIndex: number): void;
70
+ update(dt: number): void;
71
+ setStartListener(listener: Function): void;
72
+ setInterruptListener(listener: Function): void;
73
+ setEndListener(listener: Function): void;
74
+ setDisposeListener(listener: Function): void;
75
+ setCompleteListener(listener: Function): void;
76
+ setEventListener(listener: Function): void;
77
+ setTrackStartListener(entry: any, listener: Function): void;
78
+ setTrackInterruptListener(entry: any, listener: Function): void;
79
+ setTrackEndListener(entry: any, listener: Function): void;
80
+ setTrackDisposeListener(entry: any, listener: Function): void;
81
+ setTrackCompleteListener(entry: any, listener: Function): void;
82
+ setTrackEventListener(entry: any, listener: Function): void;
83
+ getState(): AnimationState;
84
+ static createWithJsonFile(skeletonDataFile: any, atlasFile: any, scale?: any): SkeletonAnimation;
85
+ static createWithBinaryFile(skeletonDataFile: any, atlasFile: any, scale?: any): SkeletonAnimation;
86
+ }
87
+ //# sourceMappingURL=CCSkeletonAnimation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CCSkeletonAnimation.d.ts","sourceRoot":"","sources":["../../../src/spine/spine-cocos/CCSkeletonAnimation.ts"],"names":[],"mappings":"AACA,OAAO,EACL,SAAS,EACT,cAAc,EACd,kBAAkB,EAKnB,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC;;;;;;;;;;;;;;;;;;;;;;;;8EAwB8E;AAE9E,eAAO,MAAM,YAAY;;;;;CAaxB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;;;;;;;CAOhC,CAAA;AAED,eAAO,MAAM,mBAAmB;;;CAiB/B,CAAA;AAiED;;;;;;;GAOG;AAEH,qBAAa,iBAAkB,SAAQ,UAAU;IAC/C,IAAI,IAAI,OAAO;IAOf,qBAAqB,CAAC,SAAS,EAAE,kBAAkB;IAOnD,MAAM,CAAC,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM;IAIzE,oBAAoB,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ;IAMpD,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO;IAS5D,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM;IAU5E,aAAa,CAAC,IAAI,EAAE,MAAM;IAI1B,UAAU,CAAC,UAAU,EAAE,MAAM;IAI7B,WAAW;IAIX,UAAU,CAAC,UAAU,EAAE,MAAM;IAI7B,MAAM,CAAC,EAAE,EAAE,MAAM;IAcjB,gBAAgB,CAAC,QAAQ,EAAE,QAAQ;IAInC,oBAAoB,CAAC,QAAQ,EAAE,QAAQ;IAIvC,cAAc,CAAC,QAAQ,EAAE,QAAQ;IAIjC,kBAAkB,CAAC,QAAQ,EAAE,QAAQ;IAIrC,mBAAmB,CAAC,QAAQ,EAAE,QAAQ;IAItC,gBAAgB,CAAC,QAAQ,EAAE,QAAQ;IAInC,qBAAqB,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ;IAIpD,yBAAyB,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ;IAIxD,mBAAmB,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ;IAIlD,uBAAuB,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ;IAItD,wBAAwB,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ;IAIvD,qBAAqB,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ;IAIpD,QAAQ;IAIR,MAAM,CAAC,kBAAkB,CAAC,gBAAgB,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,GAAG;IAI5E,MAAM,CAAC,oBAAoB,CAAC,gBAAgB,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,GAAG;CAc/E"}
@@ -1,5 +1,6 @@
1
- import * as spine from '@esotericsoftware/spine-core';
2
- import { Skeleton } from './CCSkeleton';
1
+ /* eslint-disable @typescript-eslint/no-unsafe-function-type */
2
+ import { AnimationState, AnimationStateData, AtlasAttachmentLoader, Physics, SkeletonBinary, TextureAtlas, } from '@esotericsoftware/spine-core';
3
+ import { CCSkeleton } from './CCSkeleton';
3
4
  import { SkeletonTexture } from './CCSkeletonTexture';
4
5
  /****************************************************************************
5
6
  Copyright (c) 2011-2012 cocos2d-x.org
@@ -34,7 +35,7 @@ export const _atlasLoader = {
34
35
  load: function (line) {
35
36
  const texturePath = cc.path.join(cc.path.dirname(this.spAtlasFile), line);
36
37
  const texture = cc.textureCache.addImage(texturePath);
37
- const tex = new SkeletonTexture({ width: texture.getPixelsWide(), height: texture.getPixelsHigh() });
38
+ const tex = new SkeletonTexture();
38
39
  tex.setRealTexture(texture);
39
40
  return tex;
40
41
  },
@@ -45,7 +46,7 @@ export const _atlasLoader = {
45
46
  * @constant
46
47
  * @type {{START: number, END: number, COMPLETE: number, EVENT: number}}
47
48
  */
48
- const ANIMATION_EVENT_TYPE = {
49
+ export const ANIMATION_EVENT_TYPE = {
49
50
  START: 0,
50
51
  INTERRUPT: 1,
51
52
  END: 2,
@@ -53,7 +54,7 @@ const ANIMATION_EVENT_TYPE = {
53
54
  COMPLETE: 4,
54
55
  EVENT: 5,
55
56
  };
56
- const TrackEntryListeners = function (startListener, endListener, completeListener, eventListener, interruptListener, disposeListener) {
57
+ export const TrackEntryListeners = function (startListener, endListener, completeListener, eventListener, interruptListener, disposeListener) {
57
58
  this.startListener = startListener || null;
58
59
  this.endListener = endListener || null;
59
60
  this.completeListener = completeListener || null;
@@ -121,71 +122,42 @@ TrackEntryListeners.getListeners = function (entry) {
121
122
  return entry.listener;
122
123
  };
123
124
  /**
124
- * The skeleton animation of spine. It updates animation's state and skeleton's world transform.
125
+ * The skeleton animation of It updates animation's state and skeleton's world transform.
125
126
  * @class
126
127
  * @extends Skeleton
128
+ * @example
129
+ * var spineBoy = new SkeletonAnimation('res/skeletons/spineboy.json', 'res/skeletons/spineboy.atlas');
130
+ * this.addChild(spineBoy, 4);
127
131
  */
128
- export class SkeletonAnimation extends Skeleton {
129
- _state = null;
130
- _ownsAnimationStateData = false;
131
- _listener = null;
132
- constructor(skeletonDataFile, atlasFile, scale) {
133
- super(skeletonDataFile, atlasFile, scale);
132
+ export class SkeletonAnimation extends CCSkeleton {
133
+ init() {
134
+ super.init();
134
135
  this._ownsAnimationStateData = true;
135
- this.setAnimationStateData(new spine.AnimationStateData(this._skeleton.data));
136
+ this.setAnimationStateData(new AnimationStateData(this._skeleton.data));
137
+ return true;
136
138
  }
137
- /**
138
- * Sets animation state data to SkeletonAnimation.
139
- * @param {spine.AnimationStateData} stateData
140
- */
141
139
  setAnimationStateData(stateData) {
142
- const state = new spine.AnimationState(stateData);
140
+ const state = new AnimationState(stateData);
143
141
  this._listener = new TrackEntryListeners();
144
142
  state.addListener(this._listener);
145
143
  this._state = state;
146
144
  }
147
- /**
148
- * Mix applies all keyframe values, interpolated for the specified time and mixed with the current values.
149
- * @param {String} fromAnimation
150
- * @param {String} toAnimation
151
- * @param {Number} duration
152
- */
153
145
  setMix(fromAnimation, toAnimation, duration) {
154
146
  this._state.data.setMixWith(fromAnimation, toAnimation, duration);
155
147
  }
156
- /**
157
- * Sets event listener of SkeletonAnimation.
158
- * @param {Object} target
159
- * @param {Function} callback
160
- */
161
148
  setAnimationListener(target, callback) {
162
149
  this._listener.callbackTarget = target;
163
150
  this._listener.callback = callback;
164
151
  this._listener.skeletonNode = this;
165
152
  }
166
- /**
167
- * Set the current animation. Any queued animations are cleared.
168
- * @param {Number} trackIndex
169
- * @param {String} name
170
- * @param {Boolean} loop
171
- * @returns {spine.TrackEntry|null}
172
- */
173
153
  setAnimation(trackIndex, name, loop) {
174
154
  const animation = this._skeleton.data.findAnimation(name);
175
155
  if (!animation) {
176
- cc.log(`Spine: Animation not found: ${name}`);
156
+ cc.log(`Spine: Animation not found: ${name}/${this._skeleton.data.animations.map((a) => a.name)} `);
177
157
  return null;
178
158
  }
179
159
  return this._state.setAnimationWith(trackIndex, animation, loop);
180
160
  }
181
- /**
182
- * Adds an animation to be played delay seconds after the current or last queued animation.
183
- * @param {Number} trackIndex
184
- * @param {String} name
185
- * @param {Boolean} loop
186
- * @param {Number} [delay=0]
187
- * @returns {spine.TrackEntry|null}
188
- */
189
161
  addAnimation(trackIndex, name, loop, delay) {
190
162
  delay = delay == null ? 0 : delay;
191
163
  const animation = this._skeleton.data.findAnimation(name);
@@ -195,75 +167,40 @@ export class SkeletonAnimation extends Skeleton {
195
167
  }
196
168
  return this._state.addAnimationWith(trackIndex, animation, loop, delay);
197
169
  }
198
- /**
199
- * Find animation with specified name
200
- * @param {String} name
201
- * @returns {spine.Animation|null}
202
- */
203
170
  findAnimation(name) {
204
171
  return this._skeleton.data.findAnimation(name);
205
172
  }
206
- /**
207
- * Returns track entry by trackIndex.
208
- * @param trackIndex
209
- * @returns {spine.TrackEntry|null}
210
- */
211
173
  getCurrent(trackIndex) {
212
174
  return this._state.getCurrent(trackIndex);
213
175
  }
214
- /**
215
- * Clears all tracks of animation state.
216
- */
217
176
  clearTracks() {
218
177
  this._state.clearTracks();
219
178
  }
220
- /**
221
- * Clears track of animation state by trackIndex.
222
- * @param {Number} trackIndex
223
- */
224
179
  clearTrack(trackIndex) {
225
180
  this._state.clearTrack(trackIndex);
226
181
  }
227
- /**
228
- * Update will be called automatically every frame if "scheduleUpdate" is called when the node is "live".
229
- * It updates animation's state and skeleton's world transform.
230
- * @param {Number} dt Delta time since last update
231
- * @override
232
- */
233
182
  update(dt) {
234
183
  super.update(dt);
235
184
  dt *= this._timeScale;
236
- this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.contentDirty);
185
+ if (this._renderCmd && typeof this._renderCmd.setDirtyFlag === 'function') {
186
+ this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.contentDirty);
187
+ }
237
188
  this._state.update(dt);
238
189
  this._state.apply(this._skeleton);
239
- this._skeleton.updateWorldTransform(true);
240
- this._renderCmd._updateChild();
190
+ this._skeleton.updateWorldTransform(Physics.pose);
191
+ if (this._renderCmd && typeof this._renderCmd._updateChild === 'function') {
192
+ this._renderCmd._updateChild();
193
+ }
241
194
  }
242
- /**
243
- * Set the start event listener.
244
- * @param {function} listener
245
- */
246
195
  setStartListener(listener) {
247
196
  this._listener.startListener = listener;
248
197
  }
249
- /**
250
- * Set the interrupt listener
251
- * @param {function} listener
252
- */
253
198
  setInterruptListener(listener) {
254
199
  this._listener.interruptListener = listener;
255
200
  }
256
- /**
257
- * Set the end event listener.
258
- * @param {function} listener
259
- */
260
201
  setEndListener(listener) {
261
202
  this._listener.endListener = listener;
262
203
  }
263
- /**
264
- * Set the dispose listener
265
- * @param {function} listener
266
- */
267
204
  setDisposeListener(listener) {
268
205
  this._listener.disposeListener = listener;
269
206
  }
@@ -294,18 +231,21 @@ export class SkeletonAnimation extends Skeleton {
294
231
  getState() {
295
232
  return this._state;
296
233
  }
297
- /**
298
- * Creates a skeleton animation object.
299
- * @deprecated since v3.0, please use new SkeletonAnimation(skeletonDataFile, atlasFile, scale) instead.
300
- * @param {spine.SkeletonData|String} skeletonDataFile
301
- * @param {String|spine.Atlas|spine.SkeletonData} atlasFile atlas filename or atlas data or owns SkeletonData
302
- * @param {Number} [scale]
303
- * @returns {SkeletonAnimation}
304
- */
305
234
  static createWithJsonFile(skeletonDataFile, atlasFile, scale) {
306
235
  return new SkeletonAnimation(skeletonDataFile, atlasFile, scale);
307
236
  }
308
- static create(skeletonDataFile, atlasFile, scale) {
309
- return new SkeletonAnimation(skeletonDataFile, atlasFile, scale);
237
+ static createWithBinaryFile(skeletonDataFile, atlasFile, scale) {
238
+ const dataTex = cc.loader.getRes(atlasFile);
239
+ _atlasLoader.setAtlasFile(atlasFile);
240
+ const atlas = new TextureAtlas(dataTex);
241
+ for (const page of atlas.pages) {
242
+ const texture = _atlasLoader.load(page.name);
243
+ page.setTexture(texture);
244
+ }
245
+ const attachmentLoader = new AtlasAttachmentLoader(atlas);
246
+ const skeletonBinaryReader = new SkeletonBinary(attachmentLoader);
247
+ const skeletonBinary = cc.loader.getRes(skeletonDataFile);
248
+ const skeletonData = skeletonBinaryReader.readSkeletonData(skeletonBinary);
249
+ return new SkeletonAnimation(skeletonData, true, scale);
310
250
  }
311
251
  }
@@ -0,0 +1,28 @@
1
+ /****************************************************************************
2
+ Copyright (c) 2013-2014 Chukong Technologies Inc.
3
+
4
+ http://www.cocos2d-x.org
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in
14
+ all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ THE SOFTWARE.
23
+ ****************************************************************************/
24
+ export declare const CanvasRenderCmd: {
25
+ (renderableObject: any): void;
26
+ prototype: any;
27
+ };
28
+ //# sourceMappingURL=CCSkeletonCanvasRenderCmd.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CCSkeletonCanvasRenderCmd.d.ts","sourceRoot":"","sources":["../../../src/spine/spine-cocos/CCSkeletonCanvasRenderCmd.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;8EAsB8E;AAI9E,eAAO,MAAM,eAAe;;;CAG3B,CAAA"}
@@ -0,0 +1,224 @@
1
+ /****************************************************************************
2
+ Copyright (c) 2013-2014 Chukong Technologies Inc.
3
+
4
+ http://www.cocos2d-x.org
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in
14
+ all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ THE SOFTWARE.
23
+ ****************************************************************************/
24
+ import { MeshAttachment, RegionAttachment, Utils } from '@esotericsoftware/spine-core';
25
+ export const CanvasRenderCmd = function (renderableObject) {
26
+ this._rootCtor(renderableObject);
27
+ this._needDraw = true;
28
+ };
29
+ const proto = (CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype));
30
+ proto.constructor = CanvasRenderCmd;
31
+ proto.rendering = function (wrapper, scaleX, scaleY) {
32
+ const node = this._node;
33
+ let i, n, slot, slotNode;
34
+ wrapper = wrapper || cc._renderContext;
35
+ const locSkeleton = node._skeleton, drawOrder = locSkeleton.drawOrder;
36
+ for (i = 0, n = drawOrder.length; i < n; i++) {
37
+ slot = drawOrder[i];
38
+ slotNode = slot._slotNode;
39
+ if (slotNode._visible && slotNode._renderCmd && slot.currentSprite) {
40
+ slotNode._renderCmd.transform(this, true);
41
+ slot.currentSprite._renderCmd.rendering(wrapper, scaleX, scaleY);
42
+ slotNode._renderCmd._dirtyFlag = slot.currentSprite._renderCmd._dirtyFlag = 0;
43
+ }
44
+ }
45
+ if (!node._debugSlots && !node._debugBones)
46
+ return;
47
+ wrapper.setTransform(this._worldTransform, scaleX, scaleY);
48
+ wrapper.setGlobalAlpha(1);
49
+ let attachment;
50
+ const drawingUtil = cc._drawingUtil;
51
+ if (node._debugSlots) {
52
+ // Slots.
53
+ drawingUtil.setDrawColor(0, 0, 255, 255);
54
+ drawingUtil.setLineWidth(1);
55
+ const points = [];
56
+ for (i = 0, n = locSkeleton.slots.length; i < n; i++) {
57
+ slot = locSkeleton.drawOrder[i];
58
+ if (!slot.attachment || !(slot.attachment instanceof RegionAttachment))
59
+ continue;
60
+ attachment = slot.attachment;
61
+ this._updateRegionAttachmentSlot(attachment, slot, points);
62
+ drawingUtil.drawPoly(points, 4, true);
63
+ }
64
+ }
65
+ if (node._debugBones) {
66
+ // Bone lengths.
67
+ let bone;
68
+ drawingUtil.setLineWidth(2);
69
+ drawingUtil.setDrawColor(255, 0, 0, 255);
70
+ for (i = 0, n = locSkeleton.bones.length; i < n; i++) {
71
+ bone = locSkeleton.bones[i];
72
+ const x = bone.data.length * bone.a + bone.worldX;
73
+ const y = bone.data.length * bone.c + bone.worldY;
74
+ drawingUtil.drawLine({ x: bone.worldX, y: bone.worldY }, { x: x, y: y });
75
+ }
76
+ // Bone origins.
77
+ const pointSize = 4;
78
+ drawingUtil.setDrawColor(0, 0, 255, 255); // Root bone is blue.
79
+ for (i = 0, n = locSkeleton.bones.length; i < n; i++) {
80
+ bone = locSkeleton.bones[i];
81
+ drawingUtil.drawPoint({ x: bone.worldX, y: bone.worldY }, pointSize);
82
+ if (i === 0)
83
+ drawingUtil.setDrawColor(0, 255, 0, 255);
84
+ }
85
+ }
86
+ };
87
+ proto.updateStatus = function () {
88
+ this.originUpdateStatus();
89
+ this._updateCurrentRegions();
90
+ this._regionFlag = cc.Node.CanvasRenderCmd.RegionStatus.DirtyDouble;
91
+ this._dirtyFlag &= ~cc.Node._dirtyFlags.contentDirty;
92
+ };
93
+ proto.getLocalBB = function () {
94
+ return this._node.getBoundingBox();
95
+ };
96
+ proto._updateRegionAttachmentSlot = function (attachment, slot, points) {
97
+ if (!points)
98
+ return;
99
+ const vertices = Utils.setArraySize([], 8, 0);
100
+ attachment.computeWorldVertices(slot, vertices, 0, 2);
101
+ const VERTEX = RegionAttachment;
102
+ points.length = 0;
103
+ points.push(cc.p(vertices[VERTEX.X1], vertices[VERTEX.Y1]));
104
+ points.push(cc.p(vertices[VERTEX.X4], vertices[VERTEX.Y4]));
105
+ points.push(cc.p(vertices[VERTEX.X3], vertices[VERTEX.Y3]));
106
+ points.push(cc.p(vertices[VERTEX.X2], vertices[VERTEX.Y2]));
107
+ };
108
+ proto._createChildFormSkeletonData = function () {
109
+ const node = this._node;
110
+ const locSkeleton = node._skeleton;
111
+ let spriteName, sprite;
112
+ for (let i = 0, n = locSkeleton.slots.length; i < n; i++) {
113
+ const slot = locSkeleton.slots[i], attachment = slot.attachment;
114
+ const slotNode = new cc.Node();
115
+ slot._slotNode = slotNode;
116
+ if (attachment instanceof RegionAttachment) {
117
+ spriteName = attachment.name;
118
+ sprite = this._createSprite(slot, attachment);
119
+ slot.currentSprite = sprite;
120
+ slot.currentSpriteName = spriteName;
121
+ slotNode.addChild(sprite);
122
+ }
123
+ else if (attachment instanceof MeshAttachment) {
124
+ //todo for mesh
125
+ }
126
+ }
127
+ };
128
+ const loaded = function (sprite, texture, attachment) {
129
+ const rendererObject = attachment.region;
130
+ const rect = new cc.Rect(rendererObject.x, rendererObject.y, rendererObject.width, rendererObject.height);
131
+ sprite.initWithTexture(texture, rect, rendererObject.rotate, false);
132
+ sprite._rect.width = attachment.width;
133
+ sprite._rect.height = attachment.height;
134
+ sprite.setContentSize(attachment.width, attachment.height);
135
+ sprite.setRotation(-attachment.rotation);
136
+ sprite.setScale((rendererObject.width / rendererObject.originalWidth) * attachment.scaleX, (rendererObject.height / rendererObject.originalHeight) * attachment.scaleY);
137
+ };
138
+ proto._createSprite = function (slot, attachment) {
139
+ const rendererObject = attachment.region;
140
+ const texture = rendererObject.texture.getRealTexture();
141
+ const sprite = new cc.Sprite();
142
+ if (texture.isLoaded()) {
143
+ loaded(sprite, texture, attachment);
144
+ }
145
+ else {
146
+ texture.addEventListener('load', function () {
147
+ loaded(sprite, texture, attachment);
148
+ }, this);
149
+ }
150
+ slot.sprites = slot.sprites || {};
151
+ slot.sprites[rendererObject.name] = sprite;
152
+ return sprite;
153
+ };
154
+ proto._updateChild = function () {
155
+ const locSkeleton = this._node._skeleton, slots = locSkeleton.slots;
156
+ const color = this._displayedColor, opacity = this._displayedOpacity;
157
+ let i, n, selSprite, ax, ay;
158
+ let slot, attachment, slotNode;
159
+ for (i = 0, n = slots.length; i < n; i++) {
160
+ slot = slots[i];
161
+ attachment = slot.attachment;
162
+ slotNode = slot._slotNode;
163
+ if (!attachment) {
164
+ slotNode.setVisible(false);
165
+ continue;
166
+ }
167
+ if (attachment instanceof RegionAttachment) {
168
+ if (attachment.region) {
169
+ if (!slot.currentSpriteName || slot.currentSpriteName !== attachment.name) {
170
+ const spriteName = attachment.name;
171
+ if (slot.currentSprite !== undefined)
172
+ slot.currentSprite.setVisible(false);
173
+ slot.sprites = slot.sprites || {};
174
+ if (slot.sprites[spriteName] !== undefined)
175
+ slot.sprites[spriteName].setVisible(true);
176
+ else {
177
+ const sprite = this._createSprite(slot, attachment);
178
+ slotNode.addChild(sprite);
179
+ }
180
+ slot.currentSprite = slot.sprites[spriteName];
181
+ slot.currentSpriteName = spriteName;
182
+ }
183
+ }
184
+ const bone = slot.bone;
185
+ if (attachment.region.offsetX === 0 && attachment.region.offsetY === 0) {
186
+ ax = attachment.x;
187
+ ay = attachment.y;
188
+ }
189
+ else {
190
+ //var regionScaleX = attachment.width / attachment.regionOriginalWidth * attachment.scaleX;
191
+ //ax = attachment.x + attachment.regionOffsetX * regionScaleX - (attachment.width * attachment.scaleX - attachment.regionWidth * regionScaleX) / 2;
192
+ ax = (attachment.offset[0] + attachment.offset[4]) * 0.5;
193
+ ay = (attachment.offset[1] + attachment.offset[5]) * 0.5;
194
+ }
195
+ slotNode.setPosition(bone.worldX + ax * bone.a + ay * bone.b, bone.worldY + ax * bone.c + ay * bone.d);
196
+ slotNode.setScale(bone.getWorldScaleX(), bone.getWorldScaleY());
197
+ //set the color and opacity
198
+ selSprite = slot.currentSprite;
199
+ selSprite._flippedX = bone.skeleton.flipX;
200
+ selSprite._flippedY = bone.skeleton.flipY;
201
+ if (selSprite._flippedY || selSprite._flippedX) {
202
+ slotNode.setRotation(bone.getWorldRotationX());
203
+ selSprite.setRotation(attachment.rotation);
204
+ }
205
+ else {
206
+ slotNode.setRotation(-bone.getWorldRotationX());
207
+ selSprite.setRotation(-attachment.rotation);
208
+ }
209
+ //hack for sprite
210
+ selSprite._renderCmd._displayedOpacity = 0 | (opacity * slot.color.a);
211
+ const r = 0 | (color.r * slot.color.r), g = 0 | (color.g * slot.color.g), b = 0 | (color.b * slot.color.b);
212
+ selSprite.setColor(cc.color(r, g, b));
213
+ selSprite._renderCmd._updateColor();
214
+ }
215
+ else if (attachment instanceof MeshAttachment) {
216
+ // Can not render mesh
217
+ }
218
+ else {
219
+ slotNode.setVisible(false);
220
+ continue;
221
+ }
222
+ slotNode.setVisible(true);
223
+ }
224
+ };
@@ -21,5 +21,5 @@
21
21
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
22
  THE SOFTWARE.
23
23
  ****************************************************************************/
24
- export declare const SkeletonTexture: (image: any) => void;
24
+ export declare const SkeletonTexture: () => void;
25
25
  //# sourceMappingURL=CCSkeletonTexture.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CCSkeletonTexture.d.ts","sourceRoot":"","sources":["../../../src/spine/spine-cocos/CCSkeletonTexture.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;8EAsB8E;AAI9E,eAAO,MAAM,eAAe,YAE3B,CAAA"}
@@ -1,4 +1,3 @@
1
- import * as spine from '@esotericsoftware/spine-core';
2
1
  /****************************************************************************
3
2
  Copyright (c) 2017 Chukong Technologies Inc.
4
3
 
@@ -22,12 +21,13 @@ import * as spine from '@esotericsoftware/spine-core';
22
21
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
22
  THE SOFTWARE.
24
23
  ****************************************************************************/
25
- export const SkeletonTexture = function (image) {
26
- // spine.Texture.call(this, image)
24
+ import { Texture } from '@esotericsoftware/spine-core';
25
+ export const SkeletonTexture = function () {
26
+ // Texture.call(this, image);
27
27
  };
28
- cc.inherits(SkeletonTexture, spine.Texture);
28
+ cc.inherits(SkeletonTexture, Texture);
29
29
  cc.extend(SkeletonTexture.prototype, {
30
- name: 'gworld.SkeletonTexture',
30
+ name: 'SkeletonTexture',
31
31
  _texture: null,
32
32
  setRealTexture: function (tex) {
33
33
  this._texture = tex;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CCSkeletonWebGLRenderCmd.d.ts","sourceRoot":"","sources":["../../../src/spine/spine-cocos/CCSkeletonWebGLRenderCmd.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;8EAsB8E;AAI9E,eAAO,MAAM,cAAc;;;CAS1B,CAAA"}