@urso/core 0.4.0 → 0.4.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/package.json
CHANGED
|
@@ -6,6 +6,10 @@ class ModulesObjectsModelsSpine extends Urso.Core.Modules.Objects.BaseModel {
|
|
|
6
6
|
this._addBaseObject();
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* setup params to object model
|
|
11
|
+
* @param {Object} params
|
|
12
|
+
*/
|
|
9
13
|
setupParams(params) {
|
|
10
14
|
super.setupParams(params);
|
|
11
15
|
|
|
@@ -21,11 +25,34 @@ class ModulesObjectsModelsSpine extends Urso.Core.Modules.Objects.BaseModel {
|
|
|
21
25
|
params.animation = this.animation; //we redefine original property here
|
|
22
26
|
}
|
|
23
27
|
|
|
28
|
+
/**
|
|
29
|
+
* play spine animation
|
|
30
|
+
* @param {String} animationName
|
|
31
|
+
* @param {Boolean} [loopFlag]
|
|
32
|
+
* @param {Number} [track] - you can define track number for current animation
|
|
33
|
+
*/
|
|
24
34
|
play(animationName, loopFlag = false, track = 0) {
|
|
25
35
|
this._baseObject.state.setAnimation(track, animationName, loopFlag);
|
|
26
36
|
}
|
|
27
37
|
|
|
28
|
-
|
|
38
|
+
/**
|
|
39
|
+
* stop track animation or all animations
|
|
40
|
+
* @param {Number} [track] - you can define track number to stop
|
|
41
|
+
*/
|
|
42
|
+
stop(track) {
|
|
43
|
+
if (typeof track !== 'undefined')
|
|
44
|
+
this._baseObject.state.clearTrack(track);
|
|
45
|
+
else
|
|
46
|
+
this._baseObject.state.clearTracks();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* add object to spine slot
|
|
51
|
+
* @param {Object} object - created by engine object
|
|
52
|
+
* @param {String} slotName
|
|
53
|
+
* @param {Boolean} replaceSlotContent - will replace other slot content
|
|
54
|
+
*/
|
|
55
|
+
addToSlot(object, slotName, replaceSlotContent) {
|
|
29
56
|
const spine = this._baseObject;
|
|
30
57
|
const slotIndex = spine.spineData.slots.findIndex(({ name }) => name === slotName);
|
|
31
58
|
const currentSlot = spine.slotContainers[slotIndex];
|
|
@@ -33,7 +60,12 @@ class ModulesObjectsModelsSpine extends Urso.Core.Modules.Objects.BaseModel {
|
|
|
33
60
|
if (currentSlot) {
|
|
34
61
|
object._baseObject.scale.y = -1;
|
|
35
62
|
|
|
36
|
-
Urso.objects.removeChild(object.parent, object)
|
|
63
|
+
Urso.objects.removeChild(object.parent, object);
|
|
64
|
+
|
|
65
|
+
if (replaceSlotContent)
|
|
66
|
+
currentSlot.removeChildren(); //todo check if its proxy and reset parent
|
|
67
|
+
|
|
68
|
+
//object.parent = this; //todo && make removeChild
|
|
37
69
|
currentSlot.addChild(object._baseObject);
|
|
38
70
|
} else {
|
|
39
71
|
Urso.logger.warn('ModulesObjectsModelsSpine addToSlot error: no spine slot ' + slotName);
|
|
@@ -41,7 +73,16 @@ class ModulesObjectsModelsSpine extends Urso.Core.Modules.Objects.BaseModel {
|
|
|
41
73
|
}
|
|
42
74
|
|
|
43
75
|
/**
|
|
44
|
-
*
|
|
76
|
+
* replace spine slot with new object
|
|
77
|
+
* @param {Object} object - created by engine object
|
|
78
|
+
* @param {String} slotName
|
|
79
|
+
*/
|
|
80
|
+
replaceSlotWith(object, slotName) {
|
|
81
|
+
this.addToSlot(object, slotName, true);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* set/update animation config
|
|
45
86
|
* @param {*} config
|
|
46
87
|
* @param {boolean} [noObjectCreate] dont use this flag out of core
|
|
47
88
|
*
|
|
@@ -64,6 +105,10 @@ class ModulesObjectsModelsSpine extends Urso.Core.Modules.Objects.BaseModel {
|
|
|
64
105
|
}
|
|
65
106
|
}
|
|
66
107
|
|
|
108
|
+
/**
|
|
109
|
+
* system function
|
|
110
|
+
* add object to pixi tree
|
|
111
|
+
*/
|
|
67
112
|
_addBaseObject() {
|
|
68
113
|
let spineAsset = Urso.cache.getSpine(this.assetKey);
|
|
69
114
|
|
|
@@ -81,6 +126,10 @@ class ModulesObjectsModelsSpine extends Urso.Core.Modules.Objects.BaseModel {
|
|
|
81
126
|
this.play(this.animation.name, this.animation.loop);
|
|
82
127
|
};
|
|
83
128
|
|
|
129
|
+
/**
|
|
130
|
+
* get animation timeScale
|
|
131
|
+
* @returns Number
|
|
132
|
+
*/
|
|
84
133
|
getTimeScale() {
|
|
85
134
|
return Urso.scenes.timeScale * this.animation.timeScale;
|
|
86
135
|
}
|