+2 votes

I have been working on a hidden object game for a while and I'm now at the point where I wanted to implement game pausing.

Reading the Godot 3.1 docs, I thought it would be fairly simple to do, but I hit a snag ...

small part of game screen

When I click the pause btn (yellow), and I then click a creature (red), nothing happens. Which is what I expected.
But if I then unpause the game, it seems that the click on the creature actually registered (and processing is only postponed, not ignored). The creature disappears from the scene if it was one of the creatures that had to be found.
I assume this is a Godot bug ... but does anyone have any suggestions on how I can work around this issue for now ?

Some info :
* GameRoot : has child Scene (creatures)
* Scene : has child Bar (buttons)

The pause btn is a TextureButton with the pause-mode set to 'process' in the editor.
Its code :

func _on_pause_btn_up():
    is_paused = !is_paused
    get_tree().set_deferred("paused", is_paused)

The creatures are created as an Area2D with 2 children : a Sprite and a CollisionPolygon2D.
They register clicks like this :

func on_LMB(viewport, event, shape_idx, creature_p:Area2D):
    if(event.is_action_released("LMB")):
        emit_signal("clicked", creature_p)
in Engine by (100 points)

1 Answer

0 votes
Best answer

I have the same issue ... did you solved it somehow ?

by (44 points)
selected by

Yes ... But it's more of a workaround than an real solution.

'Pause' only seems to work correctly with Controls. So :

  • if you have only a few clickable objects, you can replace the( Area2D + Sprite + CollisionPolygon2D) with a TextureButton.
    However, TextureButtons only work with rectangular clickable regions. So, if you have an irregular shape, you need to also use a ClickMask (Inspector > TextureButton > Textures : Normal (= Sprite shape) + ClickMask (= same shape as CollisionPolygon2D)). The ClickMask is a black and white bitmap (no alpha). You need to re-import it (select bitmap in //res window > import > import as bitmap). If you don't do this, it won't work !
    You can now use the click/mouse over events from the button. 'Pause' will work correctly.

  • if you have a lot of clickable objects, it's much easier to have the pause button activate a Control that covers the entire game screen (in the scene tree, it must be below your clickable objects =) ). I used a ColorRect 1920x1080px, with alpha set to 0, and mouse filter set to 'ignore'.
    When I pause the game, I only need to set the mouse filter to 'stop'. Unpause : mouse filter = 'ignore'.

HTH =)

Hi!
Thanks for your detailed answer. I also found an workaround similar to one of yours, because i really wanted to solve that issue then.
I used a MarginContainer with layout fullrect and set Mouse filter to Stop. This MarginContainer i use it as the container for my pause menu. Also set the pause mode to process for this container and everything works fine.

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.