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