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. Collision detection for Animation? [Solved]

Collision detection for Animation? [Solved]

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 2 Posters 3.1k Views
  • 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.
  • J Offline
    J Offline
    jkosonen
    wrote on last edited by
    #1

    Is it possible to add collision detection to animation so that it launches every time the animation moves?

    Example if you have PropertyAnimation on x { from: 0; to:100; duration 1000}
    Is it somehow possible to bind for example PropertyChange on x to that animation?

    Or is there any other way to make good collision detection, if you create timer, it doesn't take all pixels.. and it lags when your phone lags..

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mbrasser
      wrote on last edited by
      #2

      You could try performing the collision detection in the onXChanged handler:

      @onXChanged: detectCollisions()@

      Depending on what you are making, you might also be able to make use of something like http://gitorious.org/qml-box2d (QML bindings for Box2D).

      Regards,
      Michael

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jkosonen
        wrote on last edited by
        #3

        I tried to use onXChanged, but animation didn't trigger it.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mbrasser
          wrote on last edited by
          #4

          Hmm, it should be triggered -- can you check if the following works for you? (it should print lots of messages to the console)

          @import QtQuick 1.0

          Rectangle {
          width: 400
          height: 400

          Rectangle {
              id: rect
              width: 100
              height: 100
              color: "red"
              PropertyAnimation on x { from: 0; to: 100; duration: 1000 }
              onXChanged: console.log("x changed to " + x)
          }
          

          }@

          Regards,
          Michael

          1 Reply Last reply
          0
          • J Offline
            J Offline
            jkosonen
            wrote on last edited by
            #5

            Hey, thanks. It was Behaviour on x, that I had tried earlier!

            onXChanged worked like a charm, thanks!

            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