mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-05 06:44:56 +08:00
[as3] Fixed first frame setup pose in all timelines2
This commit is contained in:
parent
ca074364c5
commit
f85bfe5080
Binary file not shown.
@ -307,7 +307,7 @@ public class Bone implements Updatable {
|
||||
* the applied transform after the world transform has been modified directly (eg, by a constraint).
|
||||
* <p>
|
||||
* Some information is ambiguous in the world transform, such as -1,-1 scale versus 180 rotation. */
|
||||
function updateAppliedTransform () : void {
|
||||
internal function updateAppliedTransform () : void {
|
||||
appliedValid = true;
|
||||
var parent:Bone = this.parent;
|
||||
if (parent == null) {
|
||||
|
||||
@ -59,14 +59,20 @@ public class AttachmentTimeline implements Timeline {
|
||||
|
||||
public function apply (skeleton:Skeleton, lastTime:Number, time:Number, firedEvents:Vector.<Event>, alpha:Number, setupPose:Boolean, mixingOut:Boolean) : void {
|
||||
var attachmentName:String;
|
||||
if (mixingOut && setupPose) {
|
||||
var slot:Slot = skeleton.slots[slotIndex];
|
||||
var slot:Slot = skeleton.slots[slotIndex];
|
||||
if (mixingOut && setupPose) {
|
||||
attachmentName = slot.data.attachmentName;
|
||||
slot.attachment = attachmentName == null ? null : skeleton.getAttachmentForSlotIndex(slotIndex, attachmentName);
|
||||
return;
|
||||
}
|
||||
var frames:Vector.<Number> = this.frames;
|
||||
if (time < frames[0]) return; // Time is before first frame.
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
attachmentName = slot.data.attachmentName;
|
||||
slot.attachment = attachmentName == null ? null : skeleton.getAttachmentForSlotIndex(slotIndex, attachmentName);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
var frameIndex:int;
|
||||
if (time >= frames[frames.length - 1]) // Time is after last frame.
|
||||
|
||||
@ -62,7 +62,17 @@ public class ColorTimeline extends CurveTimeline {
|
||||
|
||||
override public function apply (skeleton:Skeleton, lastTime:Number, time:Number, firedEvents:Vector.<Event>, alpha:Number, setupPose:Boolean, mixingOut:Boolean) : void {
|
||||
var frames:Vector.<Number> = this.frames;
|
||||
if (time < frames[0]) return; // Time is before first frame.
|
||||
var slot:Slot = skeleton.slots[slotIndex];
|
||||
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
slot.r = slot.data.r;
|
||||
slot.g = slot.data.g;
|
||||
slot.b = slot.data.b;
|
||||
slot.a = slot.data.a;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
var r:Number, g:Number, b:Number, a:Number;
|
||||
if (time >= frames[frames.length - ENTRIES]) { // Time is after last frame.
|
||||
@ -86,8 +96,7 @@ public class ColorTimeline extends CurveTimeline {
|
||||
g += (frames[frame + G] - g) * percent;
|
||||
b += (frames[frame + B] - b) * percent;
|
||||
a += (frames[frame + A] - a) * percent;
|
||||
}
|
||||
var slot:Slot = skeleton.slots[slotIndex];
|
||||
}
|
||||
if (alpha == 1) {
|
||||
slot.r = r;
|
||||
slot.g = g;
|
||||
|
||||
@ -63,12 +63,15 @@ public class DeformTimeline extends CurveTimeline {
|
||||
if (!(slotAttachment is VertexAttachment) || !(VertexAttachment(slotAttachment)).applyDeform(attachment)) return;
|
||||
|
||||
var frames:Vector.<Number> = this.frames;
|
||||
if (time < frames[0]) return; // Time is before first frame.
|
||||
var verticesArray:Vector.<Number> = slot.attachmentVertices;
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) verticesArray.length = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
var frameVertices:Vector.<Vector.<Number>> = this.frameVertices;
|
||||
var vertexCount:int = frameVertices[0].length;
|
||||
|
||||
var verticesArray:Vector.<Number> = slot.attachmentVertices;
|
||||
|
||||
if (verticesArray.length != vertexCount) alpha = 1; // Don't mix from uninitialized slot vertices.
|
||||
verticesArray.length = vertexCount;
|
||||
var vertices:Vector.<Number> = verticesArray;
|
||||
|
||||
@ -62,9 +62,17 @@ public class DrawOrderTimeline implements Timeline {
|
||||
skeleton.drawOrder[ii] = skeleton.slots[ii];
|
||||
return;
|
||||
}
|
||||
|
||||
if (time < frames[0])
|
||||
return; // Time is before first frame.
|
||||
|
||||
var drawOrder:Vector.<Slot> = skeleton.drawOrder;
|
||||
var slots:Vector.<Slot> = skeleton.slots;
|
||||
var slot:Slot;
|
||||
var i:int = 0;
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
for each (slot in slots)
|
||||
drawOrder[i++] = slot;
|
||||
}
|
||||
}
|
||||
|
||||
var frameIndex:int;
|
||||
if (time >= frames[int(frames.length - 1)]) // Time is after last frame.
|
||||
@ -72,12 +80,10 @@ public class DrawOrderTimeline implements Timeline {
|
||||
else
|
||||
frameIndex = Animation.binarySearch1(frames, time) - 1;
|
||||
|
||||
var drawOrder:Vector.<Slot> = skeleton.drawOrder;
|
||||
var slots:Vector.<Slot> = skeleton.slots;
|
||||
var drawOrderToSetupIndex:Vector.<int> = drawOrders[frameIndex];
|
||||
var i:int = 0;
|
||||
i = 0;
|
||||
if (!drawOrderToSetupIndex) {
|
||||
for each (var slot:Slot in slots)
|
||||
for each (slot in slots)
|
||||
drawOrder[i++] = slot;
|
||||
} else {
|
||||
for each (var setupIndex:int in drawOrderToSetupIndex)
|
||||
|
||||
@ -59,9 +59,14 @@ public class IkConstraintTimeline extends CurveTimeline {
|
||||
}
|
||||
|
||||
override public function apply (skeleton:Skeleton, lastTime:Number, time:Number, firedEvents:Vector.<Event>, alpha:Number, setupPose:Boolean, mixingOut:Boolean) : void {
|
||||
if (time < frames[0]) return; // Time is before first frame.
|
||||
|
||||
var constraint:IkConstraint = skeleton.ikConstraints[ikConstraintIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
constraint.mix = constraint.data.mix;
|
||||
constraint.bendDirection = constraint.data.bendDirection;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (time >= frames[int(frames.length - ENTRIES)]) { // Time is after last frame.
|
||||
if (setupPose) {
|
||||
|
||||
@ -59,10 +59,15 @@ public class PathConstraintMixTimeline extends CurveTimeline {
|
||||
frames[frameIndex + TRANSLATE] = translateMix;
|
||||
}
|
||||
|
||||
override public function apply (skeleton:Skeleton, lastTime:Number, time:Number, firedEvents:Vector.<Event>, alpha:Number, setupPose:Boolean, mixingOut:Boolean) : void {
|
||||
if (time < frames[0]) return; // Time is before first frame.
|
||||
|
||||
override public function apply (skeleton:Skeleton, lastTime:Number, time:Number, firedEvents:Vector.<Event>, alpha:Number, setupPose:Boolean, mixingOut:Boolean) : void {
|
||||
var constraint:PathConstraint = skeleton.pathConstraints[pathConstraintIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
constraint.rotateMix = constraint.data.rotateMix;
|
||||
constraint.translateMix = constraint.data.translateMix;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
var rotate:Number, translate:Number;
|
||||
if (time >= frames[frames.length - ENTRIES]) { // Time is after last frame.
|
||||
|
||||
@ -58,10 +58,12 @@ public class PathConstraintPositionTimeline extends CurveTimeline {
|
||||
frames[frameIndex + VALUE] = value;
|
||||
}
|
||||
|
||||
override public function apply (skeleton:Skeleton, lastTime:Number, time:Number, firedEvents:Vector.<Event>, alpha:Number, setupPose:Boolean, mixingOut:Boolean) : void {
|
||||
if (time < frames[0]) return; // Time is before first frame.
|
||||
|
||||
override public function apply (skeleton:Skeleton, lastTime:Number, time:Number, firedEvents:Vector.<Event>, alpha:Number, setupPose:Boolean, mixingOut:Boolean) : void {
|
||||
var constraint:PathConstraint = skeleton.pathConstraints[pathConstraintIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) constraint.position = constraint.data.position;
|
||||
return;
|
||||
}
|
||||
|
||||
var position:Number;
|
||||
if (time >= frames[frames.length - ENTRIES]) // Time is after last frame.
|
||||
|
||||
@ -43,9 +43,11 @@ public class PathConstraintSpacingTimeline extends PathConstraintPositionTimelin
|
||||
}
|
||||
|
||||
override public function apply (skeleton:Skeleton, lastTime:Number, time:Number, firedEvents:Vector.<Event>, alpha:Number, setupPose:Boolean, mixingOut:Boolean) : void {
|
||||
if (time < frames[0]) return; // Time is before first frame.
|
||||
|
||||
var constraint:PathConstraint = skeleton.pathConstraints[pathConstraintIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) constraint.spacing = constraint.data.spacing;
|
||||
return;
|
||||
}
|
||||
|
||||
var spacing:Number;
|
||||
if (time >= frames[frames.length - ENTRIES]) // Time is after last frame.
|
||||
|
||||
@ -58,11 +58,14 @@ public class RotateTimeline extends CurveTimeline {
|
||||
}
|
||||
|
||||
override public function apply (skeleton:Skeleton, lastTime:Number, time:Number, firedEvents:Vector.<Event>, alpha:Number, setupPose:Boolean, mixingOut:Boolean) : void {
|
||||
var frames:Vector.<Number> = this.frames;
|
||||
if (time < frames[0]) return; // Time is before first frame.
|
||||
var frames:Vector.<Number> = this.frames;
|
||||
|
||||
var bone:Bone = skeleton.bones[boneIndex];
|
||||
var r:Number;
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) bone.rotation = bone.data.rotation;
|
||||
return;
|
||||
}
|
||||
|
||||
if (time >= frames[frames.length - ENTRIES]) { // Time is after last frame.
|
||||
if (setupPose)
|
||||
|
||||
@ -45,9 +45,15 @@ public class ScaleTimeline extends TranslateTimeline {
|
||||
|
||||
override public function apply (skeleton:Skeleton, lastTime:Number, time:Number, firedEvents:Vector.<Event>, alpha:Number, setupPose:Boolean, mixingOut:Boolean) : void {
|
||||
var frames:Vector.<Number> = this.frames;
|
||||
if (time < frames[0]) return; // Time is before first frame.
|
||||
|
||||
var bone:Bone = skeleton.bones[boneIndex];
|
||||
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
bone.scaleX = bone.data.scaleX;
|
||||
bone.scaleY = bone.data.scaleY;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
var x:Number, y:Number;
|
||||
if (time >= frames[frames.length - ENTRIES]) { // Time is after last frame.
|
||||
|
||||
@ -43,10 +43,16 @@ public class ShearTimeline extends TranslateTimeline {
|
||||
}
|
||||
|
||||
override public function apply (skeleton:Skeleton, lastTime:Number, time:Number, firedEvents:Vector.<Event>, alpha:Number, setupPose:Boolean, mixingOut:Boolean) : void {
|
||||
var frames:Vector.<Number> = this.frames;
|
||||
if (time < frames[0]) return; // Time is before first frame.
|
||||
|
||||
var frames:Vector.<Number> = this.frames;
|
||||
var bone:Bone = skeleton.bones[boneIndex];
|
||||
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
bone.shearX = bone.data.shearX;
|
||||
bone.shearY = bone.data.shearY;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
var x:Number, y:Number;
|
||||
if (time >= frames[frames.length - ENTRIES]) { // Time is after last frame.
|
||||
|
||||
@ -49,6 +49,9 @@ public class TrackEntry implements Poolable {
|
||||
public var timelinesFirst:Vector.<Boolean> = new Vector.<Boolean>();
|
||||
public var timelinesRotation:Vector.<Number> = new Vector.<Number>();
|
||||
|
||||
public function TrackEntry () {
|
||||
}
|
||||
|
||||
public function getAnimationTime():Number {
|
||||
if (loop) {
|
||||
var duration:Number = animationEnd - animationStart;
|
||||
|
||||
@ -62,10 +62,20 @@ public class TransformConstraintTimeline extends CurveTimeline {
|
||||
}
|
||||
|
||||
override public function apply (skeleton:Skeleton, lastTime:Number, time:Number, firedEvents:Vector.<Event>, alpha:Number, setupPose:Boolean, mixingOut:Boolean) : void {
|
||||
var frames:Vector.<Number> = this.frames;
|
||||
if (time < frames[0]) return; // Time is before first frame.
|
||||
var frames:Vector.<Number> = this.frames;
|
||||
|
||||
var constraint:TransformConstraint = skeleton.transformConstraints[transformConstraintIndex];
|
||||
var data:TransformConstraintData;
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
data = constraint.data;
|
||||
constraint.rotateMix = constraint.data.rotateMix;
|
||||
constraint.translateMix = constraint.data.translateMix;
|
||||
constraint.scaleMix = constraint.data.scaleMix;
|
||||
constraint.shearMix = constraint.data.shearMix;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
var rotate:Number, translate:Number, scale:Number, shear:Number;
|
||||
if (time >= frames[frames.length - ENTRIES]) { // Time is after last frame.
|
||||
@ -91,7 +101,7 @@ public class TransformConstraintTimeline extends CurveTimeline {
|
||||
shear += (frames[frame + SHEAR] - shear) * percent;
|
||||
}
|
||||
if (setupPose) {
|
||||
var data:TransformConstraintData = constraint.data;
|
||||
data = constraint.data;
|
||||
constraint.rotateMix = data.rotateMix + (rotate - data.rotateMix) * alpha;
|
||||
constraint.translateMix = data.translateMix + (translate - data.translateMix) * alpha;
|
||||
constraint.scaleMix = data.scaleMix + (scale - data.scaleMix) * alpha;
|
||||
|
||||
@ -59,10 +59,16 @@ public class TranslateTimeline extends CurveTimeline {
|
||||
}
|
||||
|
||||
override public function apply (skeleton:Skeleton, lastTime:Number, time:Number, firedEvents:Vector.<Event>, alpha:Number, setupPose:Boolean, mixingOut:Boolean) : void {
|
||||
var frames:Vector.<Number> = this.frames;
|
||||
if (time < frames[0]) return; // Time is before first frame.
|
||||
var frames:Vector.<Number> = this.frames;
|
||||
|
||||
var bone:Bone = skeleton.bones[boneIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
bone.x = bone.data.x;
|
||||
bone.y = bone.data.y;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
var x:Number, y:Number;
|
||||
if (time >= frames[frames.length - ENTRIES]) { // Time is after last frame.
|
||||
|
||||
Binary file not shown.
@ -40,12 +40,12 @@ public class Main extends Sprite {
|
||||
|
||||
public function Main () {
|
||||
var example:Class;
|
||||
// example = SpineboyExample;
|
||||
example = SpineboyExample;
|
||||
// example = GoblinsExample;
|
||||
// example = RaptorExample;
|
||||
// example = TankExample;
|
||||
// example = VineExample;
|
||||
example = StretchymanExample;
|
||||
// example = StretchymanExample;
|
||||
|
||||
_starling = new Starling(example, stage);
|
||||
_starling.enableErrorChecking = true;
|
||||
|
||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user