Update leenkx/Sources/iron/object/ObjectAnimation.hx
This commit is contained in:
@ -55,10 +55,23 @@ class ObjectAnimation extends Animation {
|
|||||||
oaction = getAction(this.action);
|
oaction = getAction(this.action);
|
||||||
if (oaction != null) {
|
if (oaction != null) {
|
||||||
isSampled = oaction.sampled != null && oaction.sampled;
|
isSampled = oaction.sampled != null && oaction.sampled;
|
||||||
setupDefaultSampler(onComplete, speed, loop);
|
if (defaultSampler != null) {
|
||||||
|
deRegisterAction(DEFAULT_SAMPLER_ID);
|
||||||
|
}
|
||||||
|
var callbacks = onComplete != null ? [onComplete] : null;
|
||||||
|
defaultSampler = new ActionSampler(this.action, speed, loop, false, callbacks);
|
||||||
|
registerAction(DEFAULT_SAMPLER_ID, defaultSampler);
|
||||||
|
if (paused) defaultSampler.paused = true;
|
||||||
|
updateAnimation = function(map: Map<String, FastFloat>) {
|
||||||
|
sampleAction(defaultSampler, map);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
clearDefaultSampler();
|
if (defaultSampler != null) {
|
||||||
|
deRegisterAction(DEFAULT_SAMPLER_ID);
|
||||||
|
defaultSampler = null;
|
||||||
|
}
|
||||||
|
updateAnimation = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,6 +86,7 @@ class ObjectAnimation extends Animation {
|
|||||||
transformMap = initTransformMap();
|
transformMap = initTransformMap();
|
||||||
|
|
||||||
super.update(delta);
|
super.update(delta);
|
||||||
|
if (defaultSampler != null) defaultSampler.paused = paused;
|
||||||
if (paused) return;
|
if (paused) return;
|
||||||
if (updateAnimation == null) return;
|
if (updateAnimation == null) return;
|
||||||
if (!isSkinned) updateObjectAnimation();
|
if (!isSkinned) updateObjectAnimation();
|
||||||
@ -103,39 +117,6 @@ class ObjectAnimation extends Animation {
|
|||||||
updateAnimation = f;
|
updateAnimation = f;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupDefaultSampler(onComplete: Void->Void, speed: FastFloat, loop: Bool) {
|
|
||||||
if (defaultSampler != null) {
|
|
||||||
deRegisterAction(DEFAULT_SAMPLER_ID);
|
|
||||||
defaultSampler = null;
|
|
||||||
}
|
|
||||||
var onCompleteCallbacks:Array<Void->Void> = null;
|
|
||||||
if (onComplete != null) onCompleteCallbacks = [onComplete];
|
|
||||||
defaultSampler = new ActionSampler(this.action, speed, loop, false, onCompleteCallbacks);
|
|
||||||
registerAction(DEFAULT_SAMPLER_ID, defaultSampler);
|
|
||||||
if (paused) defaultSampler.paused = true;
|
|
||||||
updateAnimation = function(map: Map<String, FastFloat>) {
|
|
||||||
sampleAction(defaultSampler, map);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function clearDefaultSampler() {
|
|
||||||
if (defaultSampler != null) {
|
|
||||||
deRegisterAction(DEFAULT_SAMPLER_ID);
|
|
||||||
defaultSampler = null;
|
|
||||||
}
|
|
||||||
updateAnimation = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
override public function pause() {
|
|
||||||
super.pause();
|
|
||||||
if (defaultSampler != null) defaultSampler.paused = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
override public function resume() {
|
|
||||||
super.resume();
|
|
||||||
if (defaultSampler != null) defaultSampler.paused = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateObjectAnimation() {
|
function updateObjectAnimation() {
|
||||||
updateAnimation(transformMap);
|
updateAnimation(transformMap);
|
||||||
updateTransform(transformMap, object.transform);
|
updateTransform(transformMap, object.transform);
|
||||||
|
Reference in New Issue
Block a user