db0 / godot-card-game-framework

A framework which comes with prepared scenes and classes to kickstart your card game, as well as a powerful scripting engine to use to provide full rules enforcement.
http://dbzer0.com/projects/godot-card-game-framework/
GNU Affero General Public License v3.0
952 stars 100 forks source link

Dragging cards shouldn't warp the mouse #52

Closed db0 closed 2 years ago

db0 commented 3 years ago

Currently I'm using a warp_mouse() workaround to avoid the card teleporting when first grabbing onto it to move around, I warp the mouse to the card location (which effectively moves it to the card's local Vector2(0,0)).

This has two issues:

I think the best solution would be if the mouse cursor was hidden, then it's intuitively more natural to understand where you want to drop the card. I did try with MOUSE_MODE_HIDDEN, but I could not combine it with MOUSE_MODE_CONFINED which is way more imporant (as unclicking the mouse outside the game can break dragging and automation which relies in mouse inputs).

Maybe a solution like suggested here: https://godotengine.org/qa/60675/make-cursor-hidden-in-mouse_mode_confined could work, to temporary replace the mouse cursor with a transparent sprite?

If the mouse cannot be made invisible, another solution would be to keep the dragged card always on the same relative spot on the mouse cursor as in the moment it was picked up. This would mean offsetting the card global placement when dragged to match the local placement of the cursor inside the card. You might still get some jitter/teleportation when picking up a card from a position next to the board edge, (especiually in the hand), but it shouldn't be too bad.

vmjcv commented 3 years ago

i will finish this