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); } }
protected internal override void step(float xOffset, float yOffset) { //Fetch information //SpriterAnimation anim = this.animation; System.Collections.Generic.IList <com.brashmonkey.spriter.animation.SpriterKeyFrame > frameList = this.animation.frames; if (this.transitionFixed && this.transitionTempFixed) { //anim = this.animation; if (this.frameSpeed >= 0) { firstKeyFrame = frameList[this.currentKey]; secondKeyFrame = frameList[(this.currentKey + 1) % frameList.Count]; } else { secondKeyFrame = frameList[this.currentKey]; firstKeyFrame = frameList[(this.currentKey + 1) % frameList.Count]; } //Update this.frame += this.frameSpeed; if (this.frame >= this.animation.length) { this.frame = 0; this.currentKey = 0; firstKeyFrame = frameList[this.currentKey]; secondKeyFrame = frameList[(this.currentKey + 1) % frameList.Count]; } if (this.currentKey == frameList.Count - 1) { frameList[0].setTime(this.animation.length); } else { frameList[0].setTime(0); if (this.frame > secondKeyFrame.getTime() && this.frameSpeed >= 0) { this.currentKey = (this.currentKey + 1) % frameList.Count; this.frame = frameList[this.currentKey].getTime(); } else { if (this.frame < firstKeyFrame.getTime()) { this.currentKey = ((this.currentKey - 1) + frameList.Count) % frameList.Count; this.frame = frameList[this.currentKey].getTime(); } } } } else { firstKeyFrame = frameList[0]; secondKeyFrame = this.lastRealFrame; float temp = (float)(this.fixCounter) / (float)this.fixMaxSteps; this.frame = this.lastRealFrame.getTime() + (long)(this.fixMaxSteps * temp); this.fixCounter = System.Math.Min(this.fixCounter + this.transitionSpeed, this.fixMaxSteps ); //Update if (this.fixCounter == this.fixMaxSteps) { this.frame = 0; this.fixCounter = 0; if (this.lastRealFrame.Equals(this.lastFrame)) { this.transitionFixed = true; } else { this.transitionTempFixed = true; } firstKeyFrame.setTime(0); } } //Interpolate this.currenObjectsToDraw = firstKeyFrame.getObjects().Length; this.currentBonesToAnimate = firstKeyFrame.getBones().Length; if (this.updateBones) { this.transformBones(firstKeyFrame, secondKeyFrame, xOffset, yOffset); } if (this.updateObjects) { this.transformObjects(firstKeyFrame, secondKeyFrame, xOffset, yOffset); } }