Hi all,

I tested the QML program below on an Android device (a tablet running Android 4.4.2). The problem is that, when rackets are not moving the ball moves smoothly (and it’s OK), but when I move either racket, it affects the speed of the ball, strangely, and reduces ball's speed! These two must be independent in terms of movement and speed, but in effect this issue takes place. I don’t know why.

Will you if possible test this code on your Android device too, to see if the problem exits there as well? If yes, what could be the source of the issue and how to remedy that, please?

main.qml:

Qt Code:
  1. import QtQuick 2.12
  2. import QtQuick.Window 2.12
  3. import QtQuick.Controls 2.5
  4.  
  5. Window {
  6. id: window
  7. visible: true
  8. width: 1000; height: 800
  9. color: "gray"
  10.  
  11. // The components
  12. // --------------
  13.  
  14. Rectangle {
  15. id: table
  16. anchors.fill: parent
  17. anchors.margins: 10
  18. y: 10
  19. anchors.horizontalCenter: parent.horizontalCenter
  20. color: "royalblue"
  21. }
  22. Racket {
  23. id: blackRacket
  24. anchors.left: table.left
  25. anchors.leftMargin: width * 2
  26. y: table.height / 2
  27. color: "black"
  28. }
  29. Racket {
  30. id: redRacket
  31. anchors.right: table.right
  32. anchors.rightMargin: width * 2
  33. y: table.height / 2
  34. color: "red"
  35. }
  36. Ball {
  37. id: ball
  38. x: 150
  39. y: 150
  40. }
  41. }
To copy to clipboard, switch view to plain text mode 


Ball.qml:

Qt Code:
  1. import QtQuick 2.12
  2.  
  3. Rectangle {
  4. width: 18; height: 18
  5. color: "white"
  6. radius: width/2
  7.  
  8. Timer { // This timer's job is merely moving the ball
  9. id: timer
  10. interval: 22; repeat: true; running: true
  11.  
  12. onTriggered: {
  13. parent.x += 0.88
  14. parent.y += 0.88
  15. }
  16. }
  17. }
To copy to clipboard, switch view to plain text mode 

Racket.qml:

Qt Code:
  1. import QtQuick 2.12
  2.  
  3. Rectangle {
  4. id: root
  5. width: 15; height: 65
  6.  
  7. MouseArea {
  8. anchors.fill: root
  9.  
  10. drag.target: root
  11. drag.axis: Drag.YAxis
  12. drag.minimumY: table.y
  13. drag.maximumY: table.height - root.height - 10
  14. }
  15. }
To copy to clipboard, switch view to plain text mode