+1 vote

In my puzzle game, every time the user levels up, a popup is shown. I make an instance of an animated scene with an overlay.

The root of the popup scene is an Area2D and it has is a CollisionShape2D as its child. I have signal connected the input_event. I want to detect if any part of the popup scene was clicked and hide it. However the input_event is only called when the popup scene is initialized (possibly while the mouse button is still clicked), but doesn't react to any inputs later on. Am I missing something?

I have similar setup for tiles in my game, but input_events work on all of the tiles just fine.

P.S. One of the children of my popup scene is a ColorFrame.

in Engine by (53 points)
edited by
  1. Which version of the engine is this in?
  2. In Godot 2.1.x, CollisionObject2D._input_event is processed last, and only if the input has not already been handled by any of the other nodes (source). This could be related to the issue, but I won't know without examining the scenes/scripts involved.
  3. Have you considered simply using a Popup-derived node instead of an Area2D for this? Using dedicated Control-derived nodes for handling UI input is going to help your project operate as expected much more easily than if you use collision-detection logic like an Area2D that is Node2D-derived.

It's Godot 2.1.4 (the one one Steam).

Then I guess, it is possible that the input is already handled by the tiles (which have the same input_event setup, but actually work as intended).

I used a scene, because I wanted the popup to look fancy (animations and all).

if you can show the code on the area script, could be helpful, maybe you are not using the exact syntax for the method.

2 Answers

+2 votes
Best answer

I finally figured it out (and tested it).

The reason why input events didn't work was the ColorFrame (I used it as a background) . Once I set Ignore Mouse to true on the ColorFrame, I was able to handle the input events.

by (53 points)
edited by
0 votes

I found a workaround for my particular case. Since I want the popup to disappear if the player clicks anywhere, instead of using input_event I can just handle inputs in _fixed_process.

func _fixed_process(delta):
    #animated is set to true, when the popup is animated
    if (Input.is_action_pressed("ui_click") && !animated):
by (53 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 Frequently asked questions and 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 [email protected] with your username.