Home‎ > ‎

Disappearing Objects

The Show/Hide, Disable/Enable, Wait Commands
It is always interesting to have objects appear and disappear. There are two ways of doing this - using the set command for the visible property and using the show/hide commands.

Once you hide an object, you may want to disable it so that it is no longer functioning. Then enable it when you want it to be active again

Show/Hide Commands
To hide an object:

       hide <object> <"name"> 

The advanced form of the hide  

       hide <object> <"name">  with visual effect <effect> <speed> with <sound>

where
    <object> can be any object type: (button, graphic, image, etc)
    <name> is the name you gave the object: ("mybox", "rocket", etc)
    <effect> is the special effect to use:
•    checkerboard - Desktop / Web / iOS  
•    venetian blinds - Desktop / Web / iOS  
•    iris close | iris open - Desktop / Web / iOS  
•    zoom close | zoom in | zoom open | zoom out - Desktop / Web / iOS  
•    wipe up | wipe down | wipe right | wipe left - Desktop / Web / iOS  
•    dissolve
•    push up | push down | push right | push left
•    reveal up | reveal down | reveal right | reveal left - Desktop / Web / iOS  
•    shrink to bottom | shrink to center | shrink to top - Desktop / Web  
•    stretch from bottom | stretch from center | stretch from top - Desktop / Web  
•    scroll up | scroll left | scroll down | scroll right - iOS / Android  
•    reveal up | reveal left | reveal down | reveal right - iOS / Android  
•    curl up | curl down - iOS  
•    flip left | flip right - iOS.  

    <speed> is how fast it disappears:  (slow, normal, fast)
    <sound> is a wav file to play:  ("poof.wav")

for example:

        hide image "diamond"
        hide graphic "myTree"
        hide button "box"

            or
   
        hide image "diamond" with visual dissolve
        hide graphic "myTree" with visual curl up with sound "yippee.wav"
        hide button "box"  with visual open barn door slow

There are many more options, look them up in the Dictionary Tool on the Edit Palette

To show them again:

        show <object> <"name">
        show <object> <"name"> with visual effect <effect> 
        show <object> <"name"> with visual effect <effect> 

where the options are the same as the hide command above

 

Disable and Enable Commands
Once you make a button (or other object) not visible, you may not want it to be "live" anymore. For example, if you have a player collecting objects (button "diamond"), once the player intersects with it, you make it disappear but you do not want it to be active anymore. Same goes for when they get points for each object - you do not want the going back and forth over the same object getting points. Another example is if a user has to collect "prizes" and once they "pick it up" (hide - prize) you don't want them to pick it up

for example:

    if intersect(button "player", button "prize", "pixels") then
        hide button "prize"
        disable button "prize"                                     (this makes it inactive)
    end if

   But do not forget to "enable" it again - when they push the "Start" button or the "Reset" button

     on mouseUp
         show button "prize"
         enable button "prize"                                     (this makes it active again)
    end mouseUp

Wait Command
The wait command allows you to pause the action or do something for a short time. It has the forms:

    wait [for]  <number>  <time>  [with messages]
    wait until  <condition> [with messages]
    wait while <condition> [with messages]
    wait for messages
    wait until  <condition> [with messages]
    wait while <condition> [with messages]
    wait for messages

where
    <number> is any number    (size, color, visible, etc)
    <time> can be any of the following:   (seconds, secs, ticks - 1/6 of a sec, milliseconds, millisecs)
    <condition> can be any expression that evaluates to "True" or "False"
     [with messages] - allows other things to happen on the screen, otherwise the program stands still

for example:

        wait for 2 seconds
        wait for 20 millisecs
        wait until the mouse is up
        wait while the seconds < timeLimit

You could do something like: 
        wait while the seconds < timeLimit

You could do something like: 
        wait while the seconds < timeLimit

You could do something like: 
        set the visible of button "ghost" to "True"
        wait for 1 sec
        wait for 1 sec
        wait for 1 sec
        set the visible of button "ghost" to "False"
    or  
        show button "ghost" 
        wait for 1 sec
        hide button "ghost" 
  


Comments