-
Notifications
You must be signed in to change notification settings - Fork 7.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Keyboard input events still working when scene is paused #3733
Comments
I guess the first title describes the issue better? Having key input enabled could be desirable for some devs(pause menus)? |
We discussed this on the community Discord when when we realized what was going on, if a scene is paused there should be a UI scene to manage its pause/unpausing/whatever else, still having any kind of input could let the users effect the game state while it should be paused. The title works either way, depending on what way you view the problem, I originally pointerdown/gameobjectdown should be triggerable when paused, however after some discussion I thought it made more sense for a UI/Paused scene to handle this instead |
The `KeyboardManager` class has been removed. It has been replaced with `KeyboardPlugin` which is now an Input level plugin, that registers itself with the new `InputPluginCache`. The Input Plugin class (which belongs to a Scene) will now automatically inject registered plugins into itself on boot. Every Scene has its own instance of the Input Plugin (if enabled in the scene plugins), which in turn has its own instance of the KeyboardPlugin. The `InputManager` no longer has any reference to the Keyboard class at all. The benefits of this are two-fold: First, it allows you to now entirely exclude all of the keyboard classes from a custom build, saving a lot of space if not required. Secondly, it means that the Scenes themselves are now responsible for keyboard events, where-as before they were entirely global. This means a Scene can be paused and stop processing keyboard events, and stop having its Key objects updated, while another Scene can still carry on doing this. It also prevents key related callbacks in sleeping Scenes from being fired (which resolves issue #3733, thanks @JoeMoov2)
This actually required a complete rewrite of the KeyboardManager. It was a global class before, not bound to a Scene, and therefore objects and events created on it applied to any Scene in your game, not just those in which they were defined. I can see how it would be useful to have this on a Scene level though. So I have created an Input Plugin system, and moved the keyboard class to it, so it's now one of the new input plugins and self-registers with the Scene input system. This means every Scene has its own instance of the keyboard plugin, which means it won't emit events (or process Key objects) for sleeping / inactive Scenes, giving full separation. It also uses more resources, but you can disable it on a per-Scene basis using the Scene config, so if you've got a Scene that doesn't need input, or keyboard input, you can disable either / or. This is now in the master branch. |
I've tried several solutions for this, it sems sprite
.on('pointerdown')
events are not able to be fired once a scene has been paused. It also seems as if scene.input.on(gameobjectdown
) events are also not able to be fired if a scene is paused.As mentioned, I've also tried the following in the
create()
and while paused got nothing backI've also tried a pointer down on a
text
object, however got the same resultThe issue here is probably more likely that keydowns are working, rather than pointerdown/gameobjectdown are not working, as if the scene is paused, it should prevent all user interaction until unpaused?
The text was updated successfully, but these errors were encountered: