0 votes

I have a game over screen in my project, that includes a try again button. I tried making it with area2D and a collision shape, with a variable mouseover controlled by the mouseentered and mouseexited signals and then emitting a signal whenever the mouse was clicked and mouseover was true.
However, most of the time, the area2D didn't detect the mouse and when it did, it was only on the edges of the collision shape - i had it print "mouse entered" and "mouseexited" in the respective functions and found out that when I moved the mouse to the edge of the collision shape, it called the function mouseentered, but when I moved it a bit inward, it called mouse_exited, even though in reality it didn't exit the collision shape. It behaved as if it was a hollow collision polygon. And that was only sometimes - sometimes the functions weren't called at all.
I tried replacing the Area2D node with a Button node (and of course altering the code to fit the Button node), which now worked every time (there wasn't a time when it wouldn't click at all) but it still only works on the edges of the button, even though the button spans the entire size off itself.

Any thoughts on what is causing this or how to fix it?

Thanks,
-Mymokol

Godot version 3.2.3
in Engine by (63 points)

1 Answer

0 votes

Is it possible that you have something covering the button? I've had that problem before. The docs say this:

Sets mouse_filter to MOUSE_FILTER_IGNORE to tell a Control node to ignore mouse or touch events. You'll need it if you place an icon on top of a button.

by (4,710 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.

Categories