效果
源码
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