/// <summary>Interpolates the bones for this animation.</summary>
 /// <remarks>Interpolates the bones for this animation.</remarks>
 /// <param name="currentFrame">first keyframe</param>
 /// <param name="nextFrame">second keyframe</param>
 /// <param name="currentAnimationTime"></param>
 /// <param name="key2StartTime"></param>
 /// <returns>interpolated SpriterBone array</returns>
 protected internal virtual void transformBones(SpriterKeyFrame
                                                currentFrame, SpriterKeyFrame nextFrame, float
                                                xOffset, float yOffset)
 {
     if (this.rootParent.getParent() != null)
     {
         this.translateRoot();
     }
     else
     {
         this.tempParent.setX(xOffset);
         this.tempParent.setY(yOffset);
         this.tempParent.setAngle(this.angle);
         this.tempParent.setScaleX(this.flippedX);
         this.tempParent.setScaleY(this.flippedY);
     }
     this.setScale(this.scale);
     if (!this.updateBones)
     {
         return;
     }
     this.updateTransformedTempObjects(nextFrame.getBones(), this.tempBones2);
     this.updateTempObjects(currentFrame.getBones(), this.nonTransformedTempBones);
     for (int i = 0; i < this.nonTransformedTempBones.Length; i++)
     {
         if (this.tempBones[i].active)
         {
             this.tweenBone(this.nonTransformedTempBones[i], nextFrame.getBoneFor(this.nonTransformedTempBones
                                                                                  [i]), i, currentFrame.getTime(), nextFrame.getTime());
         }
     }
 }
Esempio n. 2
0
 public virtual void tweenBones(SpriterAnimation animation)
 {
     foreach (SpriterBone key in bonesToTween.Keys)
     {
         SpriterBone     toTween      = key;
         SpriterKeyFrame frame        = animation.frames[bonesToTween[key]];
         long            time         = frame.getTime();
         SpriterKeyFrame currentFrame = animation.getPreviousFrameForBone
                                            (toTween, time);
         SpriterKeyFrame nextFrame = animation.getNextFrameFor
                                         (toTween, currentFrame, 1);
         if (nextFrame != currentFrame)
         {
             SpriterBone bone1 = currentFrame.getBoneFor(toTween
                                                         );
             SpriterBone bone2 = nextFrame.getBoneFor(toTween);
             this.interpolateAbstractObject(toTween, bone1, bone2, currentFrame.getTime(), nextFrame
                                            .getTime(), time);
         }
         SpriterBone[] bones = new SpriterBone
                               [frame.getBones().Length + 1];
         for (int i = 0; i < bones.Length - 1; i++)
         {
             bones[i] = frame.getBones()[i];
         }
         bones[bones.Length - 1] = toTween;
         frame.setBones(bones);
     }
 }