Discuss Scratch

Restricted
New Scratcher
12 posts

How to disable any mouse clicks on menu screen

Hi,

I have an application with a menu screen, and the user commences the game through pressing a button on a keyboard.
The game involves interaction with the mouse (especially clicking with the mouse), specifically, popping bubbles with the mouse (fun, I know). Now, even though the user cannot see the game yet, and only the menu screen (hence the game has not yet started), any clicks the user makes are registered through. How can I make it so no clicks are registered at the menu screen?

Furthermore, the game is designed in such a way that it also displays a message when the user clicks outside the map terrain, but even on the menu screen, this message can still display if the user decides to click on an area outside the terrain (even though they're in the menu screen and can't see the terrain yet). How do I make it so no message actually displays when the game has not yet commenced?

This warning message to the user is just text as a Costume in a separate Sprite, and is shown/hidden as appropriate through broadcasting.

What are some ways I can make these things happen? I was thinking about creating a boolean value and putting in place an if condition, any other ideas?

Thanks Scratch friends!
drmcw
Scratcher
1000+ posts

How to disable any mouse clicks on menu screen

Either hide the sprites responding to clicks in the menu screen or if you want them to be seen but not clickable then either use a variable like you suggest to filter out the clicks or cover the screen with one big sprite in front of the clickable sprites but behind the menu sprites and ghost it so that you can see through it.
nate2004
Scratcher
2 posts

How to disable any mouse clicks on menu screen

use the (if this sprite is clicked hide block and when flag is pressed show)
TheLogFather
Scratcher
1000+ posts

How to disable any mouse clicks on menu screen

I'm guessing you're using a construction something like this to check when the user clicks on a sprite:
whenclickedforeveriftouchingmouse-pointer?andmousedown?thenpop,etc...
Unfortunately, even hidden sprites can tell when the cursor is touching (and when the mouse button is down, of course), meaning that you need to rethink that if your sprite is hidden.

I wouldn't generally recommend doing the above, not only because of this problem, but also because the usual behaviour for clicking on some sprite would be that the user shouldn't have the mouse button down before moving over the sprite - but the above will respond if the user presses the button outside the sprite, and then drags over the sprite with the button held down. (Maybe that's not so bad for your case, though? -it seems somewhat more reasonable for ‘popping’ something…)

The usual way to detect a click on a sprite would be:
whenthisspriteclickedpop,etc...
That won't respond if the sprite is hidden (and it won't respond to a drag that moves over the sprite).

The other way to do it would be as drmcw suggests - have a variable (probably set “for this sprite only”, so you could use the same variable name in each sprite) which you change appropriately when you show/hide a clickable sprite. Then you can check if the sprite is showing before you respond.

Hope that helps!

Last edited by TheLogFather (April 18, 2014 14:14:51)

Restricted
New Scratcher
12 posts

How to disable any mouse clicks on menu screen

drmcw wrote:

Either hide the sprites responding to clicks in the menu screen or if you want them to be seen but not clickable then either use a variable like you suggest to filter out the clicks or cover the screen with one big sprite in front of the clickable sprites but behind the menu sprites and ghost it so that you can see through it.


TheLogFather wrote:

The other way to do it would be as drmcw suggests - have a variable (probably set “for this sprite only”, so you could use the same variable name in each sprite) which you change appropriately when you show/hide a clickable sprite. Then you can check if the sprite is showing before you respond.

Hope that helps!

Great thanks for the responses. I understand, and yes instead of using “When sprite is clicked…” I am detecting mouse down instead, which works fine for my intent and purposes.

However, may I ask how I would actually go about creating and maintaining the variable to filter out the clicks at the menu screen? To clarify, the sprites in-game such as the bubble and bubble pop effects upon mouse click at this point is and should not be effectuate or be visible since the user is still at the menu screen. Basically, even the main script I have when in-game responds to mouse clicks by setting variables to certain values (i.e. mouse position coordinates), but I would like none of this to happen or be processing during the main menu stage. I am not exactly sure to best approach this. Could I get some further information?

Thank you

Last edited by Restricted (April 18, 2014 15:13:08)

drmcw
Scratcher
1000+ posts

How to disable any mouse clicks on menu screen

Have a variable menu that is set to 1 when the menu is showing and 0 when not then
iftouchingmouse-pointer ?andmousedown?andmenu=0thenpop,etc...

Last edited by drmcw (April 18, 2014 16:18:42)

Restricted
New Scratcher
12 posts

How to disable any mouse clicks on menu screen

drmcw wrote:

Have a variable menu that is set to 1 when the menu is showing and 0 when not then
iftouchingmouse-pointer ?andmousedown?andmenu=0thenpop,etc...

Excellent, thank you drmcw.
multicatrain2
Scratcher
11 posts

How to disable any mouse clicks on menu screen

forum from 2014, dang.
T-o_dort
New Scratcher
1 post

How to disable any mouse clicks on menu screen

Forum from 2022, dang.

Last edited by T-o_dort (June 11, 2023 16:35:30)

Powered by DjangoBB