How to stop mouse clicks on screen?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Syl

Greets!

Here: got an animation startin at 7 mouse clicks on screen, and i want their count to stop once 7 is reached.

Here’s my lil code for that:

func _input(event):
if event is InputEventMouseButton:
	if event.button_index == BUTTON_LEFT and event.pressed:
		clicks += 1
	if clicks == 7 and event.button_index == BUTTON_LEFT and event.pressed:
		event.pressed == null
		get_node("AnimationPlayer").play("change")

But event.pressed doesn’t work, and clicks are still added… What should it be please?

:bust_in_silhouette: Reply From: Sween123

Remove the line event.pressed == null That won’t stop the scene getting mouse inputs.
create a bool variable, let’s say it’s var mouse_left_click_enabled = true

func _input(event):
if event is InputEventMouseButton:
    if mouse_left_click_enabled and event.button_index == BUTTON_LEFT and event.pressed:
        clicks += 1
        if clicks == 7:
            mouse_left_click_enabled = false
            get_node("AnimationPlayer").play("change")

Cheeeeeeeeeeeeers!

Syl | 2020-02-09 11:43