Discuss Scratch
- Discussion Forums
- » Suggestions
- » "sprite clicked?" boolean block
- DevanWolf
-
100+ posts
"sprite clicked?" boolean block
I must say to use this block:
For my example, I still want to use:
<sprite clicked?::sensing>(usually
<stage clicked?::sensing>in stage) better than:
<<mouse down?>and<touching[mouse-pointer v]?>>because it must be better excpet only whenever you hold down the mouse on the sprite it will start/report true, and if you move away from the sprite while holding down or let go it stops/reports false, but if you move your mouse back on the sprite whenever your mouse is down, then nothing will happen anymore/still reports false unless you release and click the sprite again,
For my example, I still want to use:
when flag clickedrather than:
forever
if<sprite clicked?::sensing>then
if on edge, bounce
move(5)steps
change[color v]effect by(10)
when flag clickedor:
forever
if<<mouse down?>and<touching [mouse-pointer v]?>>then
if on edge, bounce
move(5)steps
change[color v]effect by(10)
else
wait until<not<mouse down?>>
when this sprite clickedSo if this suggestion takes so long to be released, people use this workaraound:
repeat until<not<<mouse down?>and<touching [mouse-pointer v]?>>>
if on edge, bounce
move(5)steps
change[color v]effect by(10)
when this sprite clickedThen we would still use with the variable:
set[sprite clicked? v]to[true]
wait until<not<<mouse down?>and<touching [mouse-pointer v]?>>>
set[sprite clicked? v]to[false]
when flag clickedSee my project here for how the block works.
forever
if<(sprite clicked?)=[true]>then
if on edge, bounce
move(5)steps
change[color v]effect by(10)
Last edited by DevanWolf (Aug. 16, 2016 17:25:46)
- Firedrake969
-
1000+ posts
"sprite clicked?" boolean block
It's workaroundable pretty easily, so no support.
- DevanWolf
-
100+ posts
"sprite clicked?" boolean block
I think I will add a better example for a hiding sprite game, because support must be it! It's workaroundable pretty easily, so no support.
when flag clicked
go to x:(pick random(-240)to(240))y:(pick random(-180)to(180))
set[ghost v]effect to(95)
repeat until<sprite clicked?::sensing>
turn right(5)degrees
end
clear graphic effects
say[You found me!]for(2)secs
set[ghost v]effect to(100)
Last edited by DevanWolf (July 24, 2014 20:16:19)
- Firedrake969
-
1000+ posts
"sprite clicked?" boolean block
That's the same thing as repeat until touching mouse and mouse down. No support, as I've said, because of the easy workaround.
- DevanWolf
-
100+ posts
"sprite clicked?" boolean block
Read this thing again: That's the same thing as repeat until touching mouse and mouse down. No support, as I've said, because of the easy workaround.
“Whenever you hold down the mouse on the sprite it will start, and if you move away from the sprite while holding down or let go it stops, but if you move your mouse back on the sprite whenever your mouse is down, then nothing will happen anymore unless you release and click the sprite again”
- Firedrake969
-
1000+ posts
"sprite clicked?" boolean block
Read this thing again: That's the same thing as repeat until touching mouse and mouse down. No support, as I've said, because of the easy workaround.
“Whenever you hold down the mouse on the sprite it will start, and if you move away from the sprite while holding down or let go it stops, but if you move your mouse back on the sprite whenever your mouse is down, then nothing will happen anymore unless you release and click the sprite again”
forever
if <<touching [mouse v]> and <mouse down?>>
set [clicking v] to (1)
else
set [clicking v] to (0)
- DevanWolf
-
100+ posts
"sprite clicked?" boolean block
Really!? See my project on how the block works again and read the instructions on the right.Read this thing again: That's the same thing as repeat until touching mouse and mouse down. No support, as I've said, because of the easy workaround.
“Whenever you hold down the mouse on the sprite it will start, and if you move away from the sprite while holding down or let go it stops, but if you move your mouse back on the sprite whenever your mouse is down, then nothing will happen anymore unless you release and click the sprite again”forever
if <<touching [mouse v]> and <mouse down?>>
set [clicking v] to (1)
else
set [clicking v] to (0)
- Zro716
-
1000+ posts
"sprite clicked?" boolean block
how could it be any different than
when this sprite clicked
set [click v] to [true]
wait until <not <mouse down?>>
set [click v] to [false]
- DevanWolf
-
100+ posts
"sprite clicked?" boolean block
Are you sure? Read my top post carefully. how could it be any different thanwhen this sprite clicked
set [click v] to [true]
wait until <not <mouse down?>>
set [click v] to [false]
- AonymousGuy
-
1000+ posts
"sprite clicked?" boolean block
foreverWhat would you even need this for?
if <mouse down?> then
if <not <touching [mouse-pointer v]>> then
wait until <not <mouse down?>>
else
set [sprite clicked v] to [true]
wait until <not <mouse down?>>
set [sprite clicked v] to [false]
end
end
end
Last edited by AonymousGuy (July 27, 2014 14:56:07)
- Firedrake969
-
1000+ posts
"sprite clicked?" boolean block
We all have read, and you're actually somewhat denying your own suggestion by proving that there are workarounds.Are you sure? Read my top post carefully. how could it be any different thanwhen this sprite clicked
set [click v] to [true]
wait until <not <mouse down?>>
set [click v] to [false]
- AnonymousMe
-
50 posts
"sprite clicked?" boolean block
use once of these codes in this topic and put it in a custom block so you don't have to remember how to do it.
- Blaze349
-
1000+ posts
"sprite clicked?" boolean block
There is no real need for this as you just need to add two more blocks rather than one.
- Z-zap
-
100+ posts
"sprite clicked?" boolean block
I think I will add a better example for a hiding sprite game, because support must be it! It's workaroundable pretty easily, so no support.when green flag clicked
go to x:(pick random(-240)to(240))y:(pick random(-180)to(180))
set[ghost v]effect to(95)
repeat until<sprite clicked?>
turn right(5)degrees
end
clear graphic effects
say[You found me!]for(2)secs
set[ghost v]effect to(100)
when green flag clicked
go to x:(pick random(-240)to(240))y:(pick random(-180)to(180))
set[ghost v]effect to(95)
repeat until<<touching [Mousepointer v]?> and <mouse down?>>
turn right(5)degrees
end
clear graphic effects
say[You found me!]for(2)secs
set[ghost v]effect to(100)
- TheLogFather
-
1000+ posts
"sprite clicked?" boolean block
You're almost there - you only need to add a couple of extra blocks:I think I will add a better example for a hiding sprite game, because support must be it! It's workaroundable pretty easily, so no support.when green flag clicked
go to x:(pick random(-240)to(240))y:(pick random(-180)to(180))
set[ghost v]effect to(95)
repeat until<sprite clicked?>
turn right(5)degrees
end
clear graphic effects
say[You found me!]for(2)secs
set[ghost v]effect to(100)
when green flag clicked
set [sprite clicked? v] to [No]
go to x:(pick random(-240)to(240))y:(pick random(-180)to(180))
set[ghost v]effect to(95)
repeat until < (sprite clicked?) = [Yes] >
turn right(5)degrees
end
clear graphic effects
say[You found me!]for(2)secs
set[ghost v]effect to(100)
when this sprite clicked
set [sprite clicked? v] to [Yes]
BTW, as you've noticed (and @Z-zap above), it's often not really so good to use “touching mouse-pointer?” and “mouse down?” to check for clicking a sprite (also for dragging it), because it doesn't quite act in the expected way. But take a look at this demo project for a better example of how to do such things.
Hope that helps!
Last edited by TheLogFather (July 1, 2014 21:08:34)
- realmaster42
-
52 posts
"sprite clicked?" boolean block
Derp.
NO SUPPORT Because:
*trollface*
NO SUPPORT Because:
when this sprite clicked
*trollface*
- Blaze349
-
1000+ posts
"sprite clicked?" boolean block
That was unnecessary. Derp.
NO SUPPORT Because:when this sprite clicked
*trollface*
- DevanWolf
-
100+ posts
"sprite clicked?" boolean block
*BUMPS*
//I'm gonna do something with the:
<sprite clicked?::sensing>//It's really cool I still want it!
//I still want to make with the new block coming:
when flag clicked
initialize::custom//Loading
wait until<sprite clicked?::sensing>//Click the "start" button
start game::custom//Start!
...//Add more here to the game start
- TimothyLawyer
-
1000+ posts
"sprite clicked?" boolean block
It's workaroundable pretty easily, so no support.
- Discussion Forums
- » Suggestions
-
» "sprite clicked?" boolean block