kidscancode / godot_recipes

Lessons, tutorials, and guides for game development using the Godot game engine.
MIT License
240 stars 37 forks source link

[Discussion] Input: Mouse input #47

Open cbscribe opened 3 years ago

cbscribe commented 3 years ago

Discussion for http://godotrecipes.com/input/mouse_input/

boquetipo commented 3 years ago

Hi, I am trying to create a minesweeper, and there is something called "chording"; this is when left and right mouse buttons are pressed at the same time over an empty and discovered cell, with some mines around.

I have an issue with my logic, because I read the buttons pressing, but when I try to release them, I am not always able to do it physically at the same time, so button releasing is also read separately. Maybe it's easier with code:

`if (Input.is_action_just_pressed("left_click") && Input.is_action_just_pressed("right_click") && ): print('chord'); else: if (Input.is_action_just_released("left_click") && !Input.is_action_just_pressed("right_click")): <-- *

if (Input.is_action_just_released("right_click") && !Input.is_action_just_pressed("left_click")): <-- * ` * It's sometimes executed because it's difficult to release both buttons at the same time. Can I avoid this programatically?