Exemplo n.º 1
0
        public virtual com.brashmonkey.spriter.animation.SpriterKeyFrame getNextFrameFor(
            com.brashmonkey.spriter.objects.SpriterAbstractObject @object, com.brashmonkey.spriter.animation.SpriterKeyFrame
            currentFrame, int direction)
        {
            com.brashmonkey.spriter.animation.SpriterKeyFrame nextFrame = null;
            int  cnt    = 0;
            bool isBone = @object is com.brashmonkey.spriter.objects.SpriterBone;

            for (int j = (currentFrame.getId() + direction + this.numberOfFrames()) % this.numberOfFrames();
                 nextFrame == null && cnt < this.numberOfFrames(); j = (j + direction + this.numberOfFrames()) %
                                                                       this.numberOfFrames(), cnt++)
            {
                com.brashmonkey.spriter.animation.SpriterKeyFrame frame = this.frames[j];
                bool contains = (isBone) ? frame.containsBone((com.brashmonkey.spriter.objects.SpriterBone
                                                               )@object) : frame.containsObject((com.brashmonkey.spriter.objects.SpriterObject)
                                                                                                @object);
                if (contains)
                {
                    com.brashmonkey.spriter.objects.SpriterAbstractObject objectInFrame;
                    if (isBone)
                    {
                        objectInFrame = frame.getBoneFor((com.brashmonkey.spriter.objects.SpriterBone)@object);
                    }
                    else
                    {
                        objectInFrame = frame.getObjectFor((com.brashmonkey.spriter.objects.SpriterObject)@object);
                    }
                    if (@object.equals(objectInFrame))
                    {
                        nextFrame = frame;
                    }
                }
            }
            return(nextFrame);
        }
Exemplo n.º 2
0
 public virtual void tweenObjects(com.brashmonkey.spriter.animation.SpriterAnimation
                                  animation)
 {
     foreach (System.Collections.Generic.KeyValuePair <com.brashmonkey.spriter.objects.SpriterObject
                                                       , int> entry in objectsToTween.EntrySet())
     {
         com.brashmonkey.spriter.objects.SpriterObject     toTween = entry.Key;
         com.brashmonkey.spriter.animation.SpriterKeyFrame frame   = animation.frames[entry.
                                                                                      Value];
         long time = frame.getTime();
         com.brashmonkey.spriter.animation.SpriterKeyFrame currentFrame = animation.getPreviousFrameForObject
                                                                              (toTween, time);
         com.brashmonkey.spriter.animation.SpriterKeyFrame nextFrame = animation.getNextFrameFor
                                                                           (toTween, currentFrame, 1);
         if (nextFrame != currentFrame)
         {
             com.brashmonkey.spriter.objects.SpriterObject object1 = currentFrame.getObjectFor
                                                                         (toTween);
             com.brashmonkey.spriter.objects.SpriterObject object2 = nextFrame.getObjectFor(toTween
                                                                                            );
             this.interpolateSpriterObject(toTween, object1, object2, currentFrame.getTime(),
                                           nextFrame.getTime(), time);
         }
         com.brashmonkey.spriter.objects.SpriterObject[] objects = new com.brashmonkey.spriter.objects.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);
     }
 }