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); } }
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); } }
/// <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()); } } }
/// <summary>Interpolates the objects of firstFrame and secondFrame.</summary> /// <remarks>Interpolates the objects of firstFrame and secondFrame.</remarks> /// <param name="currentFrame"></param> /// <param name="nextFrame"></param> /// <param name="xOffset"></param> /// <param name="yOffset"></param> protected internal virtual void transformObjects(SpriterKeyFrame currentFrame, SpriterKeyFrame nextFrame, float xOffset, float yOffset) { this.rect.set(xOffset, yOffset, xOffset, yOffset); if (!this.updateObjects) { return; } this.updateTransformedTempObjects(nextFrame.getObjects(), this.tempObjects2); this.updateTempObjects(currentFrame.getObjects(), this.nonTransformedTempObjects); for (int i = 0; i < this.currenObjectsToDraw; i++) { if (this.tempObjects[i].active) { this.tweenObject(this.nonTransformedTempObjects[i], nextFrame.getObjectFor(this.nonTransformedTempObjects [i]), i, currentFrame.getTime(), nextFrame.getTime()); } } }