Find the Best Demos and Examples

Check out this quick tour to find the best demos and examples for you, and to see how the Felgo SDK can help you to develop your next app or game!

Forums

OverviewFelgo 2 Support (Qt 5) › NumberAnimation with multiple properties as a standalone?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #21629

    Ginzo Milani

    Is there a way to have multiple bindings?

    such as

    NumberAnimation { properties:”x,y” x:50, y:100, duration:500}

    NumberAnimation { properties:”x,y” to: {x:50,y:25}, duration: 200}

    the to function works on both properties as long as they are the same, specifying the to property as an object didn’t work unfortunately.

    I am looking for this specifically so I can dynamically specify animations without having to create/destroy animation objects constantly or store animations inline (as the properties are being read from a json and this current limitation forces me to only make sequential animations rather than “parallel” by having multiple properties adjusted on the same item)

     

    I am looking for something like

    ParallelAnimation:

    Anims = [] //array of json animations

    However the examples I’ve seen is basically creating a series of NumberAnimations to achieve the effect I’m looking for aand then removing them which seems like it could be memory expensive

    #21654

    Günther
    Felgo Team

    Hi,

    the ParallelAnimation item allows you to run multiple animations in parallel. You can also animate different properties of the same item in parallel:

    import Felgo 3.0
    import QtQuick 2.0
    
    App {  
      Rectangle {
          id: rect
          width: 100; height: 100
          color: "red"
    
          ParallelAnimation {
              running: true
              NumberAnimation { target: rect; property: "x"; to: 100; duration: 500 }
              NumberAnimation { target: rect; property: "y"; to: 250; duration: 500 }
          }
      }
    }
    

     

    Alternatively, you can also use Behaviors to animate a property as soon as it gets changed:

    import Felgo 3.0
    import QtQuick 2.0
    
    App {  
      Rectangle {
          id: rect
          width: 100; height: 100
          color: "red"
    
          Behavior on x {
              NumberAnimation { duration: 500 }
          }
          Behavior on y {
              NumberAnimation { duration: 500 }
          }
    
          MouseArea {
              anchors.fill: parent
              onClicked: {
                rect.x = 100
                rect.y = 250
              }
          }
      }
    }

     

    Best,
    Günther from Felgo

Viewing 2 posts - 1 through 2 (of 2 total)

RSS feed for this thread

You must be logged in to reply to this topic.