britzl / defold-input

Simplify input related operations such as gesture detection, input mapping and clicking/dragging game objects
MIT License
111 stars 26 forks source link

Incorrect offset of analog stick when parent is scaled #40

Open Fossean1 opened 1 month ago

Fossean1 commented 1 month ago

If you change the scale of the parent element of the analog stick, it starts to work incorrectly.

britzl commented 1 month ago

@Fossean1 could you please explain how it starts to work incorrectly. I took the example and set the analog_bg to 2x scale and it seems to work as expected.

Fossean1 commented 1 month ago

@britzl sure 🙂. Here is the problem based on an example in the "onscreen gui" project. If you make the "analog" node a parent for the "analog_bg" node and zoom in/out the "analog_bg" node, the "analog" node moves incorrectly relative to the cursor. image

https://github.com/britzl/defold-input/assets/53948838/df6db1f8-00af-4458-bf1d-5dd39716c249

britzl commented 1 month ago

Ah, ok, I see. The solution would be to somehow take the aggregated scale of the node and parent nodes into account when moving the node.