Example #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);
        }
Example #2
0
 public virtual void tweenBones(com.brashmonkey.spriter.animation.SpriterAnimation
                                animation)
 {
     foreach (System.Collections.Generic.KeyValuePair <com.brashmonkey.spriter.objects.SpriterBone
                                                       , int> entry in bonesToTween.EntrySet())
     {
         com.brashmonkey.spriter.objects.SpriterBone       toTween = entry.Key;
         com.brashmonkey.spriter.animation.SpriterKeyFrame frame   = animation.frames[entry.
                                                                                      Value];
         long time = frame.getTime();
         com.brashmonkey.spriter.animation.SpriterKeyFrame currentFrame = animation.getPreviousFrameForBone
                                                                              (toTween, time);
         com.brashmonkey.spriter.animation.SpriterKeyFrame nextFrame = animation.getNextFrameFor
                                                                           (toTween, currentFrame, 1);
         if (nextFrame != currentFrame)
         {
             com.brashmonkey.spriter.objects.SpriterBone bone1 = currentFrame.getBoneFor(toTween
                                                                                         );
             com.brashmonkey.spriter.objects.SpriterBone bone2 = nextFrame.getBoneFor(toTween);
             this.interpolateAbstractObject(toTween, bone1, bone2, currentFrame.getTime(), nextFrame
                                            .getTime(), time);
         }
         com.brashmonkey.spriter.objects.SpriterBone[] bones = new com.brashmonkey.spriter.objects.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);
     }
 }