mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
Added defaultMix to AnimationStateData.
This commit is contained in:
parent
306f394100
commit
dcbd87d90a
@ -4,6 +4,7 @@ import spine.animation.Animation;
|
|||||||
public class AnimationStateData {
|
public class AnimationStateData {
|
||||||
private var _skeletonData:SkeletonData;
|
private var _skeletonData:SkeletonData;
|
||||||
private var animationToMixTime:Object = new Object();
|
private var animationToMixTime:Object = new Object();
|
||||||
|
public var defaultMix:Number;
|
||||||
|
|
||||||
public function AnimationStateData (skeletonData:SkeletonData) {
|
public function AnimationStateData (skeletonData:SkeletonData) {
|
||||||
_skeletonData = skeletonData;
|
_skeletonData = skeletonData;
|
||||||
@ -34,7 +35,7 @@ public class AnimationStateData {
|
|||||||
public function getMix (from:Animation, to:Animation) : Number {
|
public function getMix (from:Animation, to:Animation) : Number {
|
||||||
var time:Object = animationToMixTime[from.name + ":" + to.name];
|
var time:Object = animationToMixTime[from.name + ":" + to.name];
|
||||||
if (time == null)
|
if (time == null)
|
||||||
return 0;
|
return defaultMix;
|
||||||
return time as Number;
|
return time as Number;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,6 +35,7 @@ extern "C" {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SkeletonData* const skeletonData;
|
SkeletonData* const skeletonData;
|
||||||
|
float defaultMix;
|
||||||
const void* const entries;
|
const void* const entries;
|
||||||
} AnimationStateData;
|
} AnimationStateData;
|
||||||
|
|
||||||
|
|||||||
@ -142,5 +142,5 @@ float AnimationStateData_getMix (AnimationStateData* self, Animation* from, Anim
|
|||||||
}
|
}
|
||||||
fromEntry = fromEntry->next;
|
fromEntry = fromEntry->next;
|
||||||
}
|
}
|
||||||
return 0;
|
return self->defaultMix;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,6 +30,7 @@ namespace Spine {
|
|||||||
public class AnimationStateData {
|
public class AnimationStateData {
|
||||||
public SkeletonData SkeletonData { get; private set; }
|
public SkeletonData SkeletonData { get; private set; }
|
||||||
private Dictionary<KeyValuePair<Animation, Animation>, float> animationToMixTime = new Dictionary<KeyValuePair<Animation, Animation>, float>();
|
private Dictionary<KeyValuePair<Animation, Animation>, float> animationToMixTime = new Dictionary<KeyValuePair<Animation, Animation>, float>();
|
||||||
|
public float defaultMix { get; set; }
|
||||||
|
|
||||||
public AnimationStateData (SkeletonData skeletonData) {
|
public AnimationStateData (SkeletonData skeletonData) {
|
||||||
SkeletonData = skeletonData;
|
SkeletonData = skeletonData;
|
||||||
@ -54,8 +55,8 @@ namespace Spine {
|
|||||||
public float GetMix (Animation from, Animation to) {
|
public float GetMix (Animation from, Animation to) {
|
||||||
KeyValuePair<Animation, Animation> key = new KeyValuePair<Animation, Animation>(from, to);
|
KeyValuePair<Animation, Animation> key = new KeyValuePair<Animation, Animation>(from, to);
|
||||||
float duration;
|
float duration;
|
||||||
animationToMixTime.TryGetValue(key, out duration);
|
if (animationToMixTime.TryGetValue(key, out duration)) return duration;
|
||||||
return duration;
|
return defaultMix;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -750,6 +750,7 @@ spine.AnimationStateData = function (skeletonData) {
|
|||||||
this.animationToMixTime = {};
|
this.animationToMixTime = {};
|
||||||
};
|
};
|
||||||
spine.AnimationStateData.prototype = {
|
spine.AnimationStateData.prototype = {
|
||||||
|
defaultMix: 0,
|
||||||
setMixByName: function (fromName, toName, duration) {
|
setMixByName: function (fromName, toName, duration) {
|
||||||
var from = this.skeletonData.findAnimation(fromName);
|
var from = this.skeletonData.findAnimation(fromName);
|
||||||
if (!from) throw "Animation not found: " + fromName;
|
if (!from) throw "Animation not found: " + fromName;
|
||||||
@ -762,7 +763,7 @@ spine.AnimationStateData.prototype = {
|
|||||||
},
|
},
|
||||||
getMix: function (from, to) {
|
getMix: function (from, to) {
|
||||||
var time = this.animationToMixTime[from.name + ":" + to.name];
|
var time = this.animationToMixTime[from.name + ":" + to.name];
|
||||||
return time ? time : 0;
|
return time ? time : this.defaultMix;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -32,6 +32,7 @@ public class AnimationStateData {
|
|||||||
private final SkeletonData skeletonData;
|
private final SkeletonData skeletonData;
|
||||||
final ObjectFloatMap<Key> animationToMixTime = new ObjectFloatMap();
|
final ObjectFloatMap<Key> animationToMixTime = new ObjectFloatMap();
|
||||||
final Key tempKey = new Key();
|
final Key tempKey = new Key();
|
||||||
|
float defaultMix;
|
||||||
|
|
||||||
public AnimationStateData (SkeletonData skeletonData) {
|
public AnimationStateData (SkeletonData skeletonData) {
|
||||||
this.skeletonData = skeletonData;
|
this.skeletonData = skeletonData;
|
||||||
@ -62,10 +63,18 @@ public class AnimationStateData {
|
|||||||
tempKey.a1 = from;
|
tempKey.a1 = from;
|
||||||
tempKey.a2 = to;
|
tempKey.a2 = to;
|
||||||
float time = animationToMixTime.get(tempKey, Float.MIN_VALUE);
|
float time = animationToMixTime.get(tempKey, Float.MIN_VALUE);
|
||||||
if (time == Float.MIN_VALUE) return 0;
|
if (time == Float.MIN_VALUE) return defaultMix;
|
||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float getDefaultMix () {
|
||||||
|
return defaultMix;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDefaultMix (float defaultMix) {
|
||||||
|
this.defaultMix = defaultMix;
|
||||||
|
}
|
||||||
|
|
||||||
static class Key {
|
static class Key {
|
||||||
Animation a1, a2;
|
Animation a1, a2;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user