在timeline中应用动画过渡的alpha

找到 SpineAnimationStateMixerBehaviour

// NOTE: This function is called at runtime and edit time. Keep that in mind when setting the values of properties.
public override void ProcessFrame (Playable playable, FrameData info, object playerData) {
    ...
    if (clipData.animationReference == null) {
        float mixDuration = clipData.customDuration ? clipData.mixDuration : state.Data.DefaultMix;
        state.SetEmptyAnimation(trackIndex, mixDuration);
    } else {
        if (clipData.animationReference.Animation != null) {
            Spine.TrackEntry trackEntry = state.SetAnimation(trackIndex, clipData.animationReference.Animation, clipData.loop);

            trackEntry.EventThreshold = clipData.eventThreshold;
            trackEntry.DrawOrderThreshold = clipData.drawOrderThreshold;
            trackEntry.TrackTime = (float)inputPlayable.GetTime() * (float)inputPlayable.GetSpeed();
            trackEntry.TimeScale = (float)inputPlayable.GetSpeed();
            trackEntry.AttachmentThreshold = clipData.attachmentThreshold;
            // ******apply alpha here for runtime*****
            trackEntry.Alpha = clipData.alpha;
            if (clipData.customDuration)
                trackEntry.MixDuration = clipData.mixDuration;
        }
        //else Debug.LogWarningFormat("Animation named '{0}' not found", clipData.animationName);
    }
    ...
}

public void PreviewEditModePose(Playable playable, ISkeletonComponent skeletonComponent, IAnimationStateComponent animationStateComponent, SkeletonAnimation skeletonAnimation, SkeletonGraphic skeletonGraphic) {
    ...
    // Apply Pose
    dummyAnimationState.Update(0);
    dummyAnimationState.Apply(skeleton);
} else {
    if (toAnimation != null)
        // ******apply alpha here for preview in editor*****
        toAnimation.Apply(skeleton, 0, toClipTime, clipData.loop, null, clipData.alpha, MixBlend.Setup, MixDirection.In);
    	//toAnimation.Apply(skeleton, 0, toClipTime, clipData.loop, null, 1f, MixBlend.Setup, MixDirection.In);
}
    ...
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在 JavaFX Timeline 类用于控制动画的时间线。要创建一个静止的动画,可以使用 Timeline 的 setCycleCount 方法将循环次数设置为 1,然后添加一个关键帧(KeyFrame)来控制动画的开始和结束状态。 以下是一个示例代码,其创建了一个圆形,当用户单击时,圆形将从初始位置移动到指定位置并停止: ```java import javafx.animation.KeyFrame; import javafx.animation.Timeline; import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.layout.Pane; import javafx.scene.paint.Color; import javafx.scene.shape.Circle; import javafx.stage.Stage; import javafx.util.Duration; public class StaticAnimationExample extends Application { @Override public void start(Stage primaryStage) { // 创建一个圆形 Circle circle = new Circle(50, Color.RED); circle.setTranslateX(100); circle.setTranslateY(100); // 创建一个时间线 Timeline timeline = new Timeline(); timeline.setCycleCount(1); // 添加一个关键帧来控制圆形的位置 KeyFrame keyFrame = new KeyFrame(Duration.seconds(2), event -> { circle.setTranslateX(200); circle.setTranslateY(200); }); timeline.getKeyFrames().add(keyFrame); // 将圆形添加到面板 Pane root = new Pane(circle); // 创建场景并显示舞台 Scene scene = new Scene(root, 300, 300); primaryStage.setScene(scene); primaryStage.show(); // 当用户单击时启动动画 scene.setOnMouseClicked(event -> { timeline.play(); }); } public static void main(String[] args) { launch(args); } } ``` 在该示例,创建了一个圆形,并将其添加到一个面板。然后,创建了一个 Timeline 对象并将循环次数设置为 1。接着,创建了一个关键帧来控制圆形的位置,在 2 秒后将其移动到指定位置。最后,当用户单击场景时,启动动画。当动画结束后,圆形将停留在指定位置,从而实现了静止的动画效果。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值