QML 动画(组合动画)
创始人
2024-05-29 23:24:15

在QML中,可以把多个动画组合成一个单一的动画。

组合动画的类型:

  • ParallelAnimation   动画同时进行(并行)
  • SequentialAnimation 动画按照顺序执行(顺序执行)

注意:将动画分组为“顺序动画”或“并行动画”后,无法单独启动和停止动画;顺序动画或并行动画必须作为一个组启动和停止。

ParallelAnimation的使用:

 使用时需要使用running开启

开启时,变换圆角、颜色和旋转角度 

Rectangle{id:rect1width: 200;height: 200x:150;y:150color: "lightBlue";radius: 10//创建一个并行的动画ParallelAnimation{running: true //开启并行动画NumberAnimation {  //修改圆角动画target: rect1properties: "radius"loops: Animation.Infiniteduration:2000from: 10to:50}ColorAnimation {  //修改颜色动画target: rect1properties: "color"loops: Animation.Infiniteduration:2000from:"lightBlue"to:"red"}RotationAnimation {  //修改角度动画target: rect1//properties: "rect1.rotation"loops: Animation.Infiniteduration:2000from:0to:360}}}

 SequentialAnimation的使用

 需要使用running开启

 开启时每过两秒变换一种颜色

Rectangle{id:rect1width: 200;height: 200x:150;y:150color: "lightBlue";radius: 10SequentialAnimation{running: trueColorAnimation{target: rect1properties: "color"from: "white"to: "black"duration: 2000}ColorAnimation{target: rect1properties: "color"from: "black"to: "red"duration: 2000}ColorAnimation{target: rect1properties: "color"from: "red"to: "green"duration: 2000}ColorAnimation{target: rect1properties: "color"from: "green"to: "lightBlue"duration: 2000}}}

SequentialAnimation和渐变的使用

实现使用彩色动画将天空从白天淡化到黑夜

Rectangle{id:rect1width: 400;height: 600x:150;y:0color: "lightBlue";radius: 10gradient: Gradient {GradientStop {position: 0.0SequentialAnimation on color {loops: Animation.InfiniteColorAnimation { from: "#14148c"; to: "#0E1533"; duration: 5000 }ColorAnimation { from: "#0E1533"; to: "#14148c"; duration: 5000 }}}GradientStop {position: 1.0SequentialAnimation on color {loops: Animation.InfiniteColorAnimation { from: "#14aaff"; to: "#437284"; duration: 5000 }ColorAnimation { from: "#437284"; to: "#14aaff"; duration: 5000 }}}}}

相关内容

热门资讯

重大通报作弊器!乐乐上海麻将a... 重大通报作弊器!乐乐上海麻将ai智能透视辅助插件,乐乐上海麻将本来存在有外挂(有辅助挂方略)1、很好...
分享给玩家透视挂!家乡大贰ai... 分享给玩家透视挂!家乡大贰ai智能透视辅助工具,家乡大贰其实真的有外挂(有辅助挂细节)家乡大贰破解侠...
科普攻略开挂!英豪娱乐城ai智... 科普攻略开挂!英豪娱乐城ai智能透视辅助教程,英豪娱乐城好像真的是有外挂(有辅助挂头条)1、英豪娱乐...
总算了解辅助器!和悦游戏ai智... 总算了解辅助器!和悦游戏ai智能透视辅助教程,和悦游戏确实是真的有外挂(竟然有辅助挂)暗藏猫腻,小编...
揭秘关于辅助器!九九麻将ai智... 揭秘关于辅助器!九九麻将ai智能透视辅助技巧,九九麻将一贯是有外挂(有辅助挂方略)1、用户打开应用后...