(Redirected from Hide)
Hide | |
hide | |
Category | Looks |
Type | Stack |
The Hide block is a Looks block and a stack block. If the block's sprite is shown, it will hide the sprite — if the sprite is already hidden, nothing happens. This block is one of the most commonly used Looks blocks.[citation needed] A hidden sprite cannot be touched.
Example Uses
This block is widely used, mainly in preparing scenes and such for a Scratch project. Some common uses are:
- Preparing a scene
when gf clicked hide switch costume to (ghost v) set [ghost v] effect to (100) when I receive [haunted v] show repeat (20) change [ghost v] effect by (-5) end
- Hiding a sprite in front of an object to reveal it
when gf clicked go to [front v] layer hide when I receive [chest opened v] show say [You found me!] for (2) secs
- Hiding a projectile once it hits something
when I receive [Shoot! v] show point in direction [mouse pointer v] repeat until <touching (edge v)?> move (8) steps end hide
when this sprite clicked switch costume to (empty-handed v) say [Hello and welcome to the morning news!] for (3) secs say [Oh wait, I forgot something backstage. I'll be back in a sec!] for (4) secs hide wait (2) secs show switch costume to (coffee v) say [Got my coffee! Now, where were we again?] for (2) secs
- Hiding everything but a menu or an intro at the start of a project.
when gf clicked hide when I receive [start game v] show
Workaround
- Main article: List of Block Workarounds
This block can be replicated with the following code:
set [ghost v] effect to (100)
However, this does not completely work, as it can still be sensed. Also, it reappears when the project is stopped or restarted. The hide block prevents the When this sprite clicked from activating but using ghost effects does not.
If the workaround is used, the Show block will not work. The ghost effect must then be set to 0.
Also, sprites cannot evaluate some scripts such as say and think while in hide mode, however, they can using the ghost effect. The Ask () and Wait block behaves differently on hidden sprites, the prompt is included in the ask bar.
Another workaround is switching the costume to a blank one.
switch costume to (blank costume v)
Misconceptions
A misconception is that hidden sprites will still be detected using the touching blocks. [1] Hidden sprites will not be detected. A workaround that allows detection is to set the sprite's ghost effect to 100 or by using the "clear graphic effect" block.[2]
See Also
References
- ↑ Ribsy2009. (September 9th, 2014). "If I have a hidden object (let's call it “Hidey”), will it be detected if the main sprite has the command “If touching Hidey then <whatever>” and the main sprite is touching the hidden object?" https://scratch.mit.edu/discuss/post/434362
- ↑ https://scratch.mit.edu/help/studio/tips/blocks/hide/
For sprites |
Say () for () Seconds • Say () • Think () for () Seconds • Think () • Switch Costume to () • Next Costume • Switch Backdrop to () • Next Backdrop • Change Size by () • Set Size to ()% • Change () Effect by () • Set () Effect to () • Clear Graphic Effects • Show • Hide • Go to () Layer • Go () () Layers • Costume () • Backdrop () • Size
|
For the Stage |