AnimatedSprite: reverse property



  • I'm quite new to QML and QtQuick and played around with AnimatedSprite and Animations in general.
    The following code shows a human walking foward, then he stops and walks backwards.
    @import QtQuick 2.0
    Item {
    width: 300; height: 200

    AnimatedSprite{
        id: human
        anchors.verticalCenter:  parent.verticalCenter
        width : 110
        height : 210
        source : "test.png"
        interpolate : false
        frameWidth : 109
        frameHeight : 210
        frameCount : 60
        frameRate : 20
        x : 0
        reverse : false
        property int leftPos: 0
        property int rightPos: parent.width / 1.5
        SequentialAnimation on x {
            loops: Animation.Infinite
    
            PauseAnimation { duration: 400 }
            NumberAnimation {
                from: human.leftPos; to: human.rightPos
                duration: 2100
            }
            PauseAnimation { duration: 500 }
            PropertyAction { target: human; property: "reverse"; value: true }
            PauseAnimation { duration: 500 }
    
            NumberAnimation {
                from: human.rightPos; to: human.leftPos
                duration: 2100
            }
            PauseAnimation { duration: 400 }
            PropertyAction { target: human; property: "reverse"; value: false }
        }
    }
    

    }
    @
    The walling forward animation fits to the movement (human only "walks" when his position changes), but the reverse animatione does strange things. It does not fit to the movement (even if the Pauses should be just reverted too) and the animation itself is not fluent (it is fluent however if I turn OFF interpolate).
    I tried PropertyAction with "frameX=3*109" (because the image has 3 "empty frames" in the end, which i thought could cause the problem with reverse), but things only get worse (the animation blinks at the end and is still not fitting).
    Thank you all for your time and help :)



  • It might be easier for people to help you if you could also share a link to the example pixmap as I don't know where to easily obtain that.



  • Yeah, sorry for forgetting this.
    http://jackbutnotjill.com/final_project/experiments/prototype/images/characters/m-5.png
    (I found this via "test sprite" @google images x)

    [EDIT: I use Qt 5.2-msvc2012-opengl, perhaps this information is needed too]


Log in to reply
 

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