QML —— 顺序动画,足球落地示例(附完整源码)

 

效果

 

源码
cpp 复制代码
import QtQuick 2.12
import QtQuick.Window 2.12

Window
{
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World")

    MouseArea
    {
        anchors.fill: parent
        onClicked:{setSequentialAnimationState(true)}
    }

    Component.onCompleted:{setSequentialAnimationState(false)}
    Component.onDestruction:{setSequentialAnimationState(false)}

    function setSequentialAnimationState(b)
    {
        if(b)
        {
            if(!sequentialAnimation.running){sequentialAnimation.start()}
        }
        else
        {
             if(sequentialAnimation.running){sequentialAnimation.stop()}
        }
    }

    Image
    {
        id: ballImg
        source: "ball.jpeg"
        scale: 0.3
        y: -height
        anchors.horizontalCenter: parent.horizontalCenter

        SequentialAnimation on y
        {
            id: sequentialAnimation
            loops: Animation.Infinite
            NumberAnimation
            {
                id: fallNumberAnimation
                to: ballImg.parent.height - ballImg.height
                easing.type: Easing.OutBounce
                duration: 2000
            }

            PauseAnimation {duration: 1000}

            NumberAnimation
            {
                to: -ballImg.height
                easing.type: Easing.OutQuad
                duration: 500
            }

        }
    }
}

 

关注

笔者 - jxd

 

相关推荐
扶尔魔ocy18 小时前
【qt openGL入门笔记】OSG实现飞机模型在网格图上飞行并进行态势标绘(四)
qt·opengl·osg
橙橙笔记21 小时前
QT安卓软件的制作
android·git·qt·软件
芦芭荞1 天前
QT使用xml模版生成word文档
xml·qt·word
mengzhi啊1 天前
qt把结构体数据存入json文件
qt·json
kaixin_learn_qt_ing1 天前
写入二进制文件(Qt)
qt
尘中远1 天前
QWT7 的科学 Colormap 色彩评估:QwtColorMapPreset 22 种预设的感知均匀性与场景化选
qt·qwt·科学绘图·科学配色
宿州派大星1 天前
Python实战:PyQt5 + OpenCV + Dlib 打造AI桌面应用
人工智能·python·qt
长沙红胖子Qt2 天前
Qt+TiePieHS3开发笔记(二):HS3发送器发出内置波形、直连示波器,示波器检测内置波形Demo
qt·示波器·tiepiehs3·发生器·同步发射和示波器采集
陈年老古董2 天前
PyQt5 入门指南:环境搭建、PyCharm 外部工具配置与登录界面实战
开发语言·qt·pycharm
zhanghaha13142 天前
Qt 类完整例程【逐词拆解 + 逐步骤执行保姆教程】
开发语言·qt