You know how we can show a costume when a button is clicked, e.g.
<when[ Space ]key pressed>
<switch to costume[ 1
Can we do the same with a variable. Say I have the variable "score" and I'd like to show it in front when space key is pressed. How do I do this.
Offline
Hi acevipa, you can't show and hide variables in Scratch like sprites. There are, however, several ways people have come up to deal with this.
One is to make a sprite (called e.g. score), add costumes for each number, and display / hide these costumes whenever a certain (keystroke) event occurs. There are several projects using this approach, but it's rather complicated and boring to do.
Another way is to hide the variable 'watcher' behind another 'shielding' sprite (possibly the color / texture of your background), and to hide that 'shield' whenever your event occurs. This is pretty easy to accomplish, but it might mix up your layers.
Yet another possibility is to let a sprite 'say' or 'think' the score in a speech bubble for a certain duration, after which the bubble will automatically disappear again. This is probably by far the easiest, quickest and most effective way.
If you're in a creative mood there are yet other things you could try:
e.g. you might record your own voice announcing the score and have a sprite in your project play it back as a sound, which would be kind of cool for a boxing game,
or you could let a sprite's pen 'draw' counting lines onto a virtual chalkboard on your project's background,
or you let a sound or an instument (how about a bell) sound the number of goals...
There may even be other methods I'm not aware of right now...
However, hiding and showing a variable watcher is not one of them.
Hope that helps.
-Jens
P.S. Hey, community: Can anybody think of yet other ways to announce a score in a project?
Last edited by Jens (2007-10-12 04:27:10)
Offline
some more ideas:
you could make a 'dial' sprite (sort of like a speedometer), make it point to a location on a scale, hide and show it at will...
instead of dials you could also display scores as bars or pies,
or after each goal you could stamp the soccer ball sprite onto a score-board area of the background the number of times of the score, then clear all turtle trails...
Last edited by Jens (2007-10-12 05:36:59)
Offline