@urso/core 0.4.36 → 0.4.37

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@urso/core",
3
- "version": "0.4.36",
3
+ "version": "0.4.37",
4
4
  "description": "HTML5 game engine",
5
5
  "main": "build/js/index.js",
6
6
  "author": "Megbrimef",
@@ -35,6 +35,21 @@ class ModulesObjectsModelsSpine extends Urso.Core.Modules.Objects.BaseModel {
35
35
  this._baseObject.state.setAnimation(track, animationName, loopFlag);
36
36
  }
37
37
 
38
+ /**
39
+ * set skin by name
40
+ * @param {String} skinName
41
+ */
42
+ setSkinByName(skinName) {
43
+ this._baseObject.skeleton.setSkinByName(skinName);
44
+ }
45
+
46
+ /**
47
+ * reset animation to first frame
48
+ */
49
+ setToSetupPose() {
50
+ this._baseObject.skeleton.setToSetupPose();
51
+ }
52
+
38
53
  /**
39
54
  * play spine animation and execute function after animation completes
40
55
  * @param {String} animation - name of the animation to be played
@@ -50,8 +65,24 @@ class ModulesObjectsModelsSpine extends Urso.Core.Modules.Objects.BaseModel {
50
65
  */
51
66
  playInSequence(animations) {
52
67
  this.stop();
53
- const defaultTrack = 0;
54
- animations.forEach(e => this._baseObject.state.addAnimation(defaultTrack, e));
68
+ let removeSelf = () => { };
69
+ let animationCount = 0;
70
+
71
+ const completer = {
72
+ complete: () => {
73
+ animationCount++;
74
+
75
+ if (animations[animationCount])
76
+ this.play(animations[animationCount])
77
+ else {
78
+ removeSelf();
79
+ }
80
+ }
81
+ }
82
+
83
+ removeSelf = () => this._baseObject.state.removeListener(completer);
84
+ this._baseObject.state.addListener(completer);
85
+ this.play(animations[0]);
55
86
  }
56
87
 
57
88
  /**
@@ -62,14 +93,16 @@ class ModulesObjectsModelsSpine extends Urso.Core.Modules.Objects.BaseModel {
62
93
  playInSequenceAndThen(animations, func) {
63
94
  let animationsLeft = animations.length;
64
95
  let removeSelf = () => { };
96
+
65
97
  let completer = {
66
98
  complete: () => {
67
99
  if (--animationsLeft === 0) {
68
- func();
100
+ func && func();
69
101
  removeSelf();
70
102
  }
71
103
  }
72
104
  };
105
+
73
106
  removeSelf = () => this._baseObject.state.removeListener(completer);
74
107
  this._baseObject.state.addListener(completer);
75
108
  this.playInSequence(animations);
@@ -79,7 +79,7 @@ class ModulesTemplateService {
79
79
  this._mergeStylesAndAssets({ styles: groupTemplate.styles, assets: groupTemplate.assets })
80
80
 
81
81
  //objects
82
- obj.contents = groupTemplate.objects;
82
+ obj.contents = groupTemplate.objects || [];
83
83
  }
84
84
 
85
85
  _processComponent(obj) {