[SOLVED] Why won't my animation loop? (using loops: Animation.Infinite)



  • I have this animation:
    @
    property alias angle: cloudRotation.angle; // assume this works.

        PropertyAnimation {
            id: cloudRotationAnimation;
            running: false;
            target: clouds;
            property: "angle";
            easing.type: Easing.Linear;
            to: 360;
            duration: 5000;
            loops: Animation.Infinite;
        }
    
        Component.onCompleted: {
            cloudRotationAnimation.start();
        }
    

    @
    The animation starts, but it doesn't repeat. Why not?



  • Doh. I fixed it. I had to add the "from:" property to the animation so it resets the angle back to the original value of 0 instead of animating from 360 to 360 on the second loop and onward:
    @
    property alias angle: cloudRotation.angle;
    PropertyAnimation {
    id: cloudRotationAnimation;
    running: false;
    target: clouds;
    property: "angle";
    easing.type: Easing.Linear
    from: 0; // <-- HERE
    to: 359;
    duration: 500000;
    loops: Animation.Infinite;
    }
    Component.onCompleted: {
    cloudRotationAnimation.start();
    }
    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.