鱼C论坛

 找回密码
 立即注册
查看: 2039|回复: 0

[技术原创] QT动画制作(八)

[复制链接]
发表于 2017-2-27 07:30:29 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
效果: jdfw.gif

以前我们都是单个物体运动,今天我们把多个物体组合起来一起运动
知识点1:物体群组运动
知识点2:透明度自动变化
知识点3:大小自动变化
还是先建个QML项目,在 / 下新建Rect.qml文件
  1. import QtQuick 2.4

  2. Item {
  3. Rectangle{
  4.     width:400
  5.     height:400
  6.     radius: 200
  7.     border.width: 3
  8.     border.color: "#00B000"
  9.     anchors.centerIn: parent
  10.     XAnimator on x{
  11.         from:0
  12.         to:250
  13.         duration:7000
  14.         loops:Animator.Infinite
  15.         easing.type: Easing.Linear//线性运动
  16.     }
  17.     RotationAnimator on rotation{
  18.         from:0
  19.         to:360
  20.         duration: 7000
  21.         loops:Animator.Infinite
  22.     }

  23.             Column{
  24.                 anchors.centerIn: parent
  25.                 spacing:5
  26.                 Repeater{
  27.                     model:6
  28.             Rectangle{
  29.                 width:60
  30.                 height:60
  31.                 color:"red"
  32.                 ScaleAnimator on scale{//大小变化
  33.                     from:0.1
  34.                     to:1
  35.                     duration:7000
  36.                     loops:Animator.Infinite
  37.                 }
  38.                 OpacityAnimator on opacity {//深浅度变化
  39.                     from:0.5
  40.                     to:1
  41.                     duration:7000
  42.                     loops:Animator.Infinite
  43.                 }

  44.                 }
  45.                 }
  46.             }
  47.             Row{
  48.                 anchors.centerIn: parent
  49.                 spacing:5
  50.                 Repeater{
  51.                     model:6
  52.             Rectangle{
  53.                 width:60
  54.                 height:60
  55.                 color:"red"
  56.                 ScaleAnimator on scale{//大小变化
  57.                     from:0.1
  58.                     to:1
  59.                     duration:7000
  60.                     loops:Animator.Infinite
  61.                 }
  62.                 OpacityAnimator on opacity {//深浅度变化
  63.                     from:0.5
  64.                     to:1
  65.                     duration:7000
  66.                     loops:Animator.Infinite
  67.                 }

  68.                 }
  69.                 }
  70.             }
  71. }
  72. }
复制代码


MainForm.ui.qml文件
  1. import QtQuick 2.5


  2.    Rect{anchors.centerIn: parent}

复制代码

main.qml文件
  1. import QtQuick 2.5
  2. import QtQuick.Window 2.2

  3. Window {
  4.     visible: true
  5.     width: 640
  6.     height: 480
  7.     title: qsTr("Hello World")

  8.     MainForm {
  9.         anchors.fill: parent

  10.     }
  11. }
复制代码

评分

参与人数 1荣誉 +5 鱼币 +5 贡献 +5 收起 理由
不二如是 + 5 + 5 + 5 支持楼主!

查看全部评分

本帖被以下淘专辑推荐:

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-5-3 15:16

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表