Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. AnimatedSprite: reverse property
Forum Updated to NodeBB v4.3 + New Features

AnimatedSprite: reverse property

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 1.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Banshee
    wrote on last edited by
    #1

    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 :)

    1 Reply Last reply
    0
    • J Offline
      J Offline
      Jens
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • B Offline
        B Offline
        Banshee
        wrote on last edited by
        #3

        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]

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved