In my arkanoid like game I have bar and the ball which interacts with that bar, or rather which should interacts with the bar, because I have no idea how to deliver this.

I create both ball and bar in the my js script and place them in specific location on the grid (which is an item defined in main.qml). But know I am facing the problem
1. how to implement moving the ball with the bar at the same time if ball lies on the bar ? Currently bar is moved with drag.** properties set in Bar.qml, and it works great, because I can click and press the bar and it moves , but how to inform the ball object to move also but only if it knows it lies on the bar

Qt Code:
  1. import QtQuick 1.0
  2. import "logic/barMechanics.js" as BAR_MECHANIC
  3.  
  4. Rectangle {
  5. id: bar
  6. smooth: true
  7. radius: 30
  8. opacity: 0.9
  9. gradient: Gradient {
  10. GradientStop { position: 0.0 ; color: "red"}
  11. GradientStop { position: 0.5 ; color: "yellow" }
  12. GradientStop { position: 1.0 ; color: "black"}
  13. }
  14.  
  15. signal clicked;
  16. property bool sticky: false //this property if true means that ball does not bounce from bar but gets atteched to it
  17.  
  18. MouseArea { //!!!! <--- CUSTOMIZE IT ---> !!!!//
  19. id: mouseArea
  20. anchors.fill: bar
  21. drag.target: bar
  22. drag.axis: Drag.XAxis
  23. drag.minimumX: 0
  24. drag.maximumX: bar.parent.width - bar.width + 10
  25.  
  26. onPressed: BAR_MECHANIC.barMoving(); //sets anchor to undefined
  27. }
  28. }
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. import QtQuick 1.0
  2.  
  3. ///there will be three possible bal (red,green,blue)
  4.  
  5. Item {
  6. id: bal
  7. property int type: 0
  8. property bool nitro: false //ball goes fast
  9. property bool destroyer: false //ball do not bounce from obstacles it goes throught them crushig em
  10. property bool onBar: false
  11.  
  12. //setting the bal colour
  13. Image {
  14. id: bal_colour
  15. anchors.fill: bal
  16. smooth: true
  17. source: {
  18. if(type == 0){
  19. return "resources/redBall.png";
  20. }else if (type == 1){
  21. return "resources/yellowBall.png";
  22. }else{
  23. return "resources/greenBall.png"
  24. }
  25. }
  26. }
  27. MouseArea {
  28. id: ballMouseArea
  29. anchors.fill: parent
  30. }
  31. }
To copy to clipboard, switch view to plain text mode 

any suggestion ? if any other code part is required let me know...