Discuss Scratch

ethereal_cymatic
Scratcher
11 posts

How to make sprites temporarily unclickable?

Hi, I’m making a two player balloon pop game and I’d like to prevent player 2 from being able to click their balloons while it is player 1’s turn. And the same for player 1’s turn. Any ideas on how to achieve this?

Here’s is the project so far

https://scratch.mit.edu/projects/1047106155
deck26
Scratcher
1000+ posts

How to make sprites temporarily unclickable?

Use a variable and check the value when a balloon is clicked - if the value is wrong the click doesn't do anything.
BigNate469
Scratcher
1000+ posts

How to make sprites temporarily unclickable?

Use
when green flag clicked
forever
if <<(Player Turn:) = [this player]> and <<mouse down?> and <touching [mouse-pointer v] ?>>> then
Do everything you currently do under the "when this sprite clicked" blocks; the code from both blocks can go here. :: grey
end
end
in the balloon sprites. Get rid of your
when this sprite clicked
blocks, and replace “this player” above with whichever player's balloon it is (the balloon will only pop when Player Turn: is set to this value).

Last edited by BigNate469 (July 22, 2024 16:58:12)

deck26
Scratcher
1000+ posts

How to make sprites temporarily unclickable?

No need to get rid of the ‘when this sprite clicked’ scripts if you prefer to keep them - just add an if block to check the variable that indicates whose turn it is.

Powered by DjangoBB