Topic was automatically imported from the old Question2Answer platform.
Asked By
Robster
Old Version
Published before Godot 3 was released.
Hi all,
This code:
func input(event):
if (event.type==InputEvent.MOUSE_BUTTON and event.is_action_released("mouse_clicked") and !event.is_echo()):
print("yup, you clicked it")
print("Mouse mode: ", str(Input.get_mouse_mode()))
prints the following:
yup, you clicked it
Mouse mode: 32767
yup, you clicked it
Mouse mode: 32767
I think the default should have been MOUSE_VISIBLE, so you could call OS.set_mouse_mode(MOUSE_VISIBLE) when your game starts (or whatever value you want) so it gets an initial value.
Zylann | 2017-02-09 03:39
Thank you. I tried to add OS.set_mouse_mode(MOUSE_VISIBLE) to my func _ready(): but got this error:
Parser Error: Identifier not found: MOUSE_VISIBLE
EDIT: I also tried MOUSE_MODE_VISIBLE and 0 with the same issue
Robster | 2017-02-09 03:42
Sorry, the constant is Input.MOUSE_MODE_VISIBLE.
If the returned mouse mode is higher than the maximum one, just assume it’s Input.MOUSE_MODE_VISIBLE.
Zylann | 2017-02-09 03:46
Thank you, adding Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) to the func _input(event): worked. I really appreciate your help. I’d have never figured that one out!
Robster | 2017-02-09 03:52
No, don’t put it in _event, put it in _ready or some other place it would run only at game start ;).