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

#1 2011-01-28 22:04:57

mrhozer
New Scratcher
Registered: 2011-01-28
Posts: 4

Key held down (not mouse button)??? Need quick help.

Hi guys, I'm sure this had been addressed plenty of times, but I can't find the solution in any forums I've looked through.

So... I'm trying to make an Asteroids style game, and need to have a variable turn on (switched to the number "1") for as long as the button is held down, then turning the variable back to off (the number 0) once the button is released.

Thanks in advance  smile

Offline

 

#2 2011-01-28 22:08:20

jeffy24
Scratcher
Registered: 2008-12-23
Posts: 61

Re: Key held down (not mouse button)??? Need quick help.

Easy. Just find the [block]<mouse down?>[/block] and use variables and the [block]<<  <not>  >>[/block] block..

Last edited by jeffy24 (2011-01-28 22:08:41)


I'M A CREEPER http://4.bp.blogspot.com/-Fj1t1TmbPtc/UAp3ludvGCI/AAAAAAAAAlI/RXSkO96QN20/s1600/creeper.png

Offline

 

#3 2011-01-28 22:32:46

mrhozer
New Scratcher
Registered: 2011-01-28
Posts: 4

Re: Key held down (not mouse button)??? Need quick help.

Thanks for the fast reply,

I actually was looking for a key held down, not the mouse button. I found a solution shortly after posting.

I just put it in a:
When 'up key' pressed:
  Forever:
      If  <up arrow pressed>
           move 10 steps
      </if>
   </forever>

-------------------
Thanks!

Offline

 

#4 2011-01-28 23:47:49

mrhozer
New Scratcher
Registered: 2011-01-28
Posts: 4

Re: Key held down (not mouse button)??? Need quick help.

oops... I meant "When 'up arrow" pressed" on the first line

Offline

 

#5 2011-01-29 13:28:26

bbbeb
Scratcher
Registered: 2009-06-11
Posts: 1000+

Re: Key held down (not mouse button)??? Need quick help.

[When green flag pressed]
[forever]
[if <key [up arrow] pressed>]
[][(insert block here)]
[endif]
[endforever]


Back in my day.... there were no laws that censored the internet... now, there are.... nah.

Offline

 

#6 2011-01-30 11:29:15

markyparky56
Scratcher
Registered: 2008-03-20
Posts: 1000+

Re: Key held down (not mouse button)??? Need quick help.

Shouldn't this be better suited in All about scratch? Maybe?


http://j.mp/jgVnTq
Check out my game engine development site: NewDawn I'm a Level 171 Scratcher.I am http://bit.ly/nkvLNT

Offline

 

#7 2011-01-30 11:47:52

fullmoon
Retired Community Moderator
Registered: 2007-06-04
Posts: 1000+

Re: Key held down (not mouse button)??? Need quick help.

markyparky56 wrote:

Shouldn't this be better suited in All about scratch? Maybe?

Right. Moving.


http://i302.photobucket.com/albums/nn100/fullmoon32/wow.jpg

Offline

 

#8 2011-01-30 14:26:16

GraemeK
Scratcher
Registered: 2010-06-14
Posts: 73

Re: Key held down (not mouse button)??? Need quick help.

This would actually be better as the script is only actually running when the up arrow key is pressed.
http://scratchr.webs.com/images/ifup.gif


http://internetometer.com/image/13865.png

Offline

 

#9 2011-01-30 14:37:40

kayybee
Scratcher
Registered: 2009-12-07
Posts: 1000+

Re: Key held down (not mouse button)??? Need quick help.

When flag clicked
forever
if <up pressed>
set _____ to 1
else
set _____ to 0

Offline

 

#10 2011-01-30 17:33:31

HydraRancher
Scratcher
Registered: 2010-03-07
Posts: 9

Re: Key held down (not mouse button)??? Need quick help.

GraemeK wrote:

This would actually be better as the script is only actually running when the up arrow key is pressed.
http://scratchr.webs.com/images/ifup.gif

It is less efficient because that control has a short delay when detecting.

Offline

 

#11 2011-01-31 11:11:27

markyparky56
Scratcher
Registered: 2008-03-20
Posts: 1000+

Re: Key held down (not mouse button)??? Need quick help.

HydraRancher wrote:

GraemeK wrote:

This would actually be better as the script is only actually running when the up arrow key is pressed.
http://scratchr.webs.com/images/ifup.gif

It is less efficient because that control has a short delay when detecting.

Well then simply put it in a
[blocks]
<when green flag clicked>
[/blocks]
block.


http://j.mp/jgVnTq
Check out my game engine development site: NewDawn I'm a Level 171 Scratcher.I am http://bit.ly/nkvLNT

Offline

 

Board footer