Depress mouse/keyboard key action

Hi,

When switching from a scene to scene using mouse button pressed (or touch), the mouse button will stay pressed and possibly hit another button in the new scene.

Example scenario:
Scene 1 has an “OK” button in center. If clicked by mouse, scene 2 gets activated.
Scene 2 has an “OK” button in center as well. But mouse button will still be clicked, and it will automatically get activated before the user has a chance to decide whether he/she wants to activate this button or not.

Another example, imagine our platform character passing scene 1 and going to scene 2. He may continue running until we press another button. But it would be better if he doesn’t keep running.

Surely there are ways to work around this inside of gdevelop, but it would be simplest/easiest if there was an action event to “depress” mouse and keyboard button(s), so that the user has to press the button again before it gets detected in the new scene, so I am suggesting such an action block which would mostly be used together with “At the beginning of the scene” condition, but can be used at any point as desired, for various purposes.

I solved this using a variable this way:

if mouse button is not pressed, do 1 to variable mouseEnable;

if mouse button is pressed and if variable mouseEnable is = 1, do whatever;

here’s the image:
imgur.com/a/OtDvC

I think it’s almost as quick as the feature you’re requesting.

As far as the other inputs are concerned, since i use input buffers anyway for the sake of responsiveness, i just assign a variable for each input.

(This way, for example, if the player character is jumping and has almost reached the floor, pressing the jump key again just before he reaches the floor will result in a second jump. I also use variables to store which key has been pressed the last if both left and right key are held down at the same time, so the player character moves in that direction.)

Just use “key released” and “mouse button released” instead, this is how most UI works. Instead of acting on “press”, act on “release”

Thanks for your replies guys. I think it will be helpful that you’ve mentioned a lot of ways to do this.

You can definitely work around the issue in gdevelop, and this is not something I’m arguing (it’s not at all impossible to use the inputs as they currently are or anything of the sort). You’ve so far mentioned buffered variables and mouse release instead of click, thanks for the tips again.

While both of these might work well, comparing to having to store variables, I would just personally find it easier in some cases to have an action to depress (potentially all) keys on scene load, and let gdevelop handle the input buffers (which it probably does already, in which case it might be easier to add this action, but I’m not sure - this is something that the developer would know). If I need to depress mouse button after opening of a menu, then that’s one more action, but it might still be less actions than variables.

As for using mouse button release, I have considered this, but I’m not sure if this is optimal both for web and android devices. E.g. I’ve tested some games, and some buttons would actually work when you release the touch, but others would work immediately after touching (before you release). On windows, some functions (e.g. some menu’s) activate themselves immediately on mouse key press (before you release it), while others wait for release. Funny thing is that other things activate on release, so you could e.g. click your mouse on “Help” menu within a program, hold the mouse button, and release it on “About”, and it would actually open the “About” dialogue, so you would do two actions (Help + About) with just one mouse click. It’s probably not supposed to work that way, but it does.

Regardless of being able to solve the problem, if gdevelop does have an internal buffer for keypresses (so it doesn’t take too much work for the developer), I would love for some depress actions to exist (depress all inputs, and depress specific input), to make some things simpler. We need to manage buffers in Javascript ourselves with variables, but with this command we wouldn’t necessarily have to do so in gdevelop (depending on usage case).

Another example is the platformer behavior with no special events. Once your character passes from scene 1 to scene 2, you likely won’t immediately depress the keyboard key so he/she will continue running in the 2nd level until you do. This is not necessarily an issue and probably happens in some games and not in other, but I would prefer that you have to physically depress and press the key again before the next scene. This is where a “depress all keys” on scene load would come in handy.

There don’t seem to be any hard-coded input buffers, you have to make them yourself. But I agree with you.
It must be hard for the developers to find the right balance between enough actions and too many actions to scroll through.

I haven’t really had much trouble with the issues you’re mentioning, but the thing I kind of miss frequently is the possibility to check for collision and other conditions among copies of the same object. (Though this is somewhat off-topic.)

Can you describe an exact scenario? Off topic or not, I’d like to explore it, and if possible, offer advice (or maybe others can). Well, there isn’t going to be too many actions very easily. They are grouped well, so you are not spammed with a thousand of actions at the same time.