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

#1 2009-12-07 14:34:27

snoweater
Scratcher
Registered: 2009-12-07
Posts: 1

Sensing and if block a key pressed vs. when key pressed

I wanted to make my sprite move up when the up arrow is pressed.  Originally, I used the if block with the condition from the sensing section so it was if key <up arrow> is pressed?

but it didn't work.

I finally discovered the When key <up arrow> is pressed ....
that worked but it would seem to me that the if block should work.  Has anyone else have this trouble?  Why have the key pressed under sensing if it cannot be used?

Offline

 

#2 2009-12-07 14:49:04

Targethero
Scratcher
Registered: 2008-09-08
Posts: 1000+

Re: Sensing and if block a key pressed vs. when key pressed

I does work. Were you useing: When Flag Clicked, forever, if key 'up arrow' pressed, change y by 10? Because it will work that way.


http://img97.imageshack.us/img97/3981/targethero2.png http://ls.gd/bo

Offline

 

#3 2009-12-08 05:15:01

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: Sensing and if block a key pressed vs. when key pressed

This is the structure you want (that Targethero describes above) ...

[blocks]
<when green flag clicked>
<forever>
<if><key[ Up Arrow ]pressed?>
<change y by( 10
<end>
<end>
[/blocks]

If you don't have the Forever loop around it, then the test will only take place once (when the Green Flag is clicked).  You need for the test to happen over and over again.


http://i39.tinypic.com/2nav6o7.gif

Offline

 

Board footer