Ejemplo n.º 1
0
 public virtual void tweenObjects(SpriterAnimation animation)
 {
     foreach (SpriterObject key in objectsToTween.Keys)
     {
         SpriterObject   toTween      = key;
         SpriterKeyFrame frame        = animation.frames[objectsToTween[key]];
         long            time         = frame.getTime();
         SpriterKeyFrame currentFrame = animation.getPreviousFrameForObject
                                            (toTween, time);
         SpriterKeyFrame nextFrame = animation.getNextFrameFor
                                         (toTween, currentFrame, 1);
         if (nextFrame != currentFrame)
         {
             SpriterObject object1 = currentFrame.getObjectFor
                                         (toTween);
             SpriterObject object2 = nextFrame.getObjectFor(toTween
                                                            );
             this.interpolateSpriterObject(toTween, object1, object2, currentFrame.getTime(),
                                           nextFrame.getTime(), time);
         }
         SpriterObject[] objects = new SpriterObject
                                   [frame.getObjects().Length + 1];
         for (int i = 0; i < objects.Length - 1; i++)
         {
             objects[i] = frame.getObjects()[i];
         }
         objects[objects.Length - 1] = toTween;
         frame.setObjects(objects);
     }
 }
Ejemplo 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);
     }
 }