This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-03-16 09:29:22

weechees
New Scratcher
Registered: 2011-03-16
Posts: 2

Letting go of a key

I'm making a project right now and I need some help.
I've set it so that when space is pressed, the power (variable) will increase.
But I need to know how to stop the script when I let go of space, so the variable won't change.

Offline

 

#2 2011-03-16 10:31:11

YourLocalBlockLib
Scratcher
Registered: 2011-03-10
Posts: 100+

Re: Letting go of a key

[blocks]<repeat until><not><key[ space ]pressed?>>>
<change{ power }by( 1[/blocks]

~~Scimonster


http://dl.dropbox.com/u/6273449/BlockLibraryTitle.png

Offline

 

#3 2011-03-16 11:18:13

3DBlenderRender
Scratcher
Registered: 2011-03-10
Posts: 44

Re: Letting go of a key

Or, better yet,

Forever:

If: Key Space Pressed,
Then: Change Variable X by +1

Else: Stop Script

(Stop script can be found under "Control", near the bottom, and is not "Stop All", just "Stop Script". It's a really useful little block for multi-stage games.)

There. That should do the trick. What are you working on? A car simulation? I've done a ton of those on my computer, if you ever need help on those. I love working with Car Physics.

- 3DBlenderRender

Offline

 

#4 2011-03-16 11:54:14

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Letting go of a key

3DBlenderRender wrote:

Or, better yet,

Forever:

If: Key Space Pressed,
Then: Change Variable X by +1

Else: Stop Script

(Stop script can be found under "Control", near the bottom, and is not "Stop All", just "Stop Script". It's a really useful little block for multi-stage games.)

There. That should do the trick. What are you working on? A car simulation? I've done a ton of those on my computer, if you ever need help on those. I love working with Car Physics.

- 3DBlenderRender

Except that will, as it sounds, stop the script, which we don't want.


http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#5 2011-03-17 04:51:44

weechees
New Scratcher
Registered: 2011-03-16
Posts: 2

Re: Letting go of a key

Sorry if I didn't make it very clear, what I really wanted was to make the script so that

when i press SPACE the power will increase by 1
then, once i let go of space, i broadcast something, and stop the script that increases the power

Hope this makes things clearer

Offline

 

#6 2011-03-18 00:17:03

floppy_gunk
Scratcher
Registered: 2008-11-14
Posts: 500+

Re: Letting go of a key

[blocks]
<when[ space ]key pressed>
<repeat until><<  <not><key[ space ]pressed?>  >>
<change{ power }by( 1
<end>
<broadcast[ something
[/blocks]

Last edited by floppy_gunk (2011-03-18 00:18:53)


http://img163.imageshack.us/img163/1917/2856lg.jpg Get it now!  smile

Offline

 

Board footer