How Felgo,
Have few questions related to MouseJoint, hopefully you will be able to answer them.
In general I followed docs: https://felgo.com/doc/mousejoint/#example-usage
1. How to create MouseJoint?
If I follow exactly the docs, so
– MouseArea.onPressed
: creates dynamically MouseJoint, set target
, set bodyB
(exactly in this order)
– MouseArea.onPositionChanged
: changes target
to new point
– MouseArea.onReleased
: destroys MouseJoint
behavior is fine.
Is this the only valid way, to create every time MouseJoint dynamically and destroy it quickly on release, and repeat?
2. Create one MouseJoint and reuse it/control it MouseArea
Unfortunately I had tons of issues if I tried to create one MouseJoint
with targetB set once and change target later in MouseArea.
Then the behavior is really weird …
One of the way to mimic this behavior is to follow the docs but change order of things.
From:
// set the target point to the current mouse position
mouseJointWhileDragging.target = Qt.point(mouseX, mouseY)
// set the body to move to the currently selected one
mouseJointWhileDragging.bodyB = selectedBody
to:
// set the body to move to the currently selected one
mouseJointWhileDragging.bodyB = selectedBody
// set the target point to the current mouse position
mouseJointWhileDragging.target = Qt.point(mouseX, mouseY)
3. MouseJoint behavior
This is probably how MouseJoint should behave, but it “moves” bodyB
to selected target
BUT keeps the distance between the touch and bodyB fixed.
This is probably how it should work.
The side effect is it never moves it to exactly target
position but by vector from bodyB
position to new coordinates.
Looks like to make MouseJoint working you need to exacly follow the way described in docs, if you do things in a different order then you will have problems.
Is this expected?