Discuss Scratch

purpleguystoast
Scratcher
16 posts

When Sprite Clicked

Hi- for my game, when a sprite (that isn't the player) is clicked, i want the player to say something. I was thinking of trying this:
when this sprite clicked
broadcast [clicked]

And then for the player sprite:
when I receive [clicked]
say [---] for (2) secs

Can anyone tell me if there's any script better than this one?
bRuHbRuHmEmEmAn
Scratcher
100+ posts

When Sprite Clicked

Yeah, that works. If you want to use fewer blocks, that's the perfect method. If not, then here you go.

when green flag clicked
forever
if <<touching [mouse-pointer v] ?> and <mouse down?>> then
set [SpriteWasClicked v] to [yes]
end
end

And in the player sprite:

when green flag clicked
forever
if <(SpriteWasClicked) = [yes]> then
say [Hello!] for (2) secs
end
end

(#`Д´ :: #999999) (#`Д´ :: #999999) (#`Д´ :: #999999) (#`Д´ :: #999999) (#`Д´ :: #999999) (#`Д´ :: #999999) (#`Д´ :: #999999) (#`Д´ :: #999999) (#`Д´ :: #999999) (#`Д´ :: #999999) (#`Д´ :: #999999) (#`Д´ :: #999999) (#`Д´ :: #999999)(#`Д´ :: #999999)(#`Д´ :: #999999) (#`Д´ :: #999999) (#`Д´ :: #999999):: reporter :: #444444 // First line of defense - Gunners

(‡▼益▼:: #ff4444) (‡▼益▼:: #ff4444) (‡▼益▼:: #ff4444) (‡▼益▼:: #ff4444) (‡▼益▼:: #ff4444) (‡▼益▼:: #ff4444) (‡▼益▼:: #ff4444) (‡▼益▼:: #ff4444) (‡▼益▼:: #ff4444) (‡▼益▼:: #ff4444) (‡▼益▼:: #ff4444) (‡▼益▼:: #ff4444) (‡▼益▼:: #ff4444) (‡▼益▼:: #ff4444) (‡▼益▼:: #ff4444) (‡▼益▼:: #ff4444) :: reporter :: #aa0000 // Second line of defense - Heavy Gunners

(╬◣_◢ :: #44ff44) (╬◣_◢ :: #44ff44) (╬◣_◢ :: #44ff44) (╬◣_◢ :: #44ff44) (╬◣_◢ :: #44ff44) (╬◣_◢ :: #44ff44) (╬◣_◢ :: #44ff44) (╬◣_◢ :: #44ff44) (╬◣_◢ :: #44ff44) (╬◣_◢ :: #44ff44) (╬◣_◢ :: #44ff44) (╬◣_◢ :: #44ff44) (╬◣_◢ :: #44ff44) (╬◣_◢ :: #44ff44) (╬◣_◢ :: #44ff44) (╬◣_◢ :: #44ff44) :: reporter :: #00aa00 // Third line of defense - Tanks n' Stuff

(≖、≖╬ :: #4444ff) (≖、≖╬ :: #4444ff) (≖、≖╬ :: #4444ff) (≖、≖╬ :: #4444ff) (≖、≖╬ :: #4444ff) (≖、≖╬ :: #4444ff) (≖、≖╬ :: #4444ff) (≖、≖╬ :: #4444ff) (≖、≖╬ :: #4444ff) (≖、≖╬ :: #4444ff) (≖、≖╬ :: #4444ff) (≖、≖╬ :: #4444ff) (≖、≖╬ :: #4444ff) (≖、≖╬ :: #4444ff) (≖、≖╬ :: #4444ff) (≖、≖╬ :: #4444ff) (≖、≖╬ :: #4444ff) (≖、≖╬ :: #4444ff) (≖、≖╬ :: #4444ff) (≖、≖╬ :: #4444ff) (≖、≖╬ :: #4444ff) :: reporter :: #0000aa // Final line of defense - Death Rays
A message from the founder of bRuHbRuHmEmEmAn's signature defense

There's no possible way the kumquats can get through this, amirite folks?
Your average HwS fourm roamer. Ask me anything.

Before you ask, yes, I am a furry, and if you're thinking in your head “eww a furry,” then please do your research. Furries aren't bad people. Well, most of them.
ayyyyes10135
Scratcher
100+ posts

When Sprite Clicked

forever
if <<touching [ mouse pointer] ?> and <mouse down?>> then
broadcast [ clicked]
wait until <not <mouse down?>>

end
end

this broadcasts too. the wait untill not mouse down makes it so that it wont spam

YOOOOOOO 100 POSTS LETS GO

________________________________________

give me ideas on what to create. im so bored every day. yeah i should probably doing my project but NO IDEAS!!!
cwknikhil15842
Scratcher
100+ posts

When Sprite Clicked

Try this:


Subscribe to my YouTube channel

when green flag clicked
forever
Imagine ::operators
Program ::sensing
Share! ::sound
end
ayyyyes10135
Scratcher
100+ posts

When Sprite Clicked

cwknikhil15842 wrote:

Try this:



that wouldnt work because you have to do the code first otherwise the wait untill block will only make it so that the code will do it after you release the mouse

YOOOOOOO 100 POSTS LETS GO

________________________________________

give me ideas on what to create. im so bored every day. yeah i should probably doing my project but NO IDEAS!!!
purpleguystoast
Scratcher
16 posts

When Sprite Clicked

Hi! I just released my game. https://scratch.mit.edu/projects/500005387
The sprite I needed to be clicked on was the kid on the first level when you start the game. (I am adding more)
cwknikhil15842
Scratcher
100+ posts

When Sprite Clicked

ayyyyes10135 wrote:

cwknikhil15842 wrote:

Try this:



that wouldnt work because you have to do the code first otherwise the wait untill block will only make it so that the code will do it after you release the mouse
Isn't that how a when sprite clicked works?

Subscribe to my YouTube channel

when green flag clicked
forever
Imagine ::operators
Program ::sensing
Share! ::sound
end
Idkdidntask
Scratcher
7 posts

When Sprite Clicked

well i think try this:

when green flag clicked
go to front

[scratchblocks]
when this sprite clicked
repeat (2)
create clone of [myself v]
go to [random position v]
play sound [chord v]
end
[/scratchblocks]

assignisions:


[scratchblocks]
when green flag clicked
imagine
program
add (letter (s) of [and share]) to [list v]
[/scratchblocks]

[scratchblocks]
(O) _ (O)
[/scratchblocks]

[scratchblocks]
when green flag clicked
forever
forever
forever
forever
forever
forever
forever
forever
forever
forever
set [my variable v] to [1]
end
[/scratchblocks]

Last edited by Idkdidntask (Jan. 13, 2023 12:57:50)

Idkdidntask
Scratcher
7 posts

When Sprite Clicked

Greypath wrote:

A salt seller used to carry the salt bag on his donkey to the market every day.

On the way they had to cross a stream. One day the donkey suddenly tumbled down the stream and the salt bag also fell into the water. The salt dissolved in the water and hence the bag became very light to carry. The donkey was happy.

Then the donkey started to play the same trick every day.

The salt seller came to understand the trick and decided to teach a lesson to it. The next day he loaded a cotton bag on the donkey.

Again it played the same trick hoping that the cotton bag would be still become lighter.

But the dampened cotton became very heavy to carry and the donkey suffered. It learnt a lesson. It didn’t play the trick anymore after that day, and the seller was happy.

what
deck26
Scratcher
1000+ posts

When Sprite Clicked

Greypath wrote:

A salt seller used to carry the salt bag on his donkey to the market every day.

On the way they had to cross a stream. One day the donkey suddenly tumbled down the stream and the salt bag also fell into the water. The salt dissolved in the water and hence the bag became very light to carry. The donkey was happy.

Then the donkey started to play the same trick every day.

The salt seller came to understand the trick and decided to teach a lesson to it. The next day he loaded a cotton bag on the donkey.

Again it played the same trick hoping that the cotton bag would be still become lighter.

But the dampened cotton became very heavy to carry and the donkey suffered. It learnt a lesson. It didn’t play the trick anymore after that day, and the seller was happy.
Please don't spam. This has nothing to do with the topic.

Powered by DjangoBB