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

#1 2012-07-10 11:45:26

gemerl20
New Scratcher
Registered: 2012-07-09
Posts: 5

How to sense when a button is released?

When I want my sprite to move, it's costume needs to change to a different one while it is running, and then change back to its original costume when it finishes moving. How do I achieve changing its costume back?

Here's what I have so far:

[scratchblocks]
when gf clicked
forever
  wait until <key [a] is pressed>
  move [-10] steps
  repeat until []
    switch to costume [costume5]
  end
end

Offline

 

#2 2012-07-10 11:48:44

gemerl20
New Scratcher
Registered: 2012-07-09
Posts: 5

Re: How to sense when a button is released?

Oops, I meant to say this:


when gf clicked
forever
  wait until <key [a] is pressed>
  move [-10] steps
  repeat until []
    switch to costume [costume5]
  end
end
I need to figure out what to put next to "repeat until."

Offline

 

#3 2012-07-10 11:55:04

gemerl20
New Scratcher
Registered: 2012-07-09
Posts: 5

Re: How to sense when a button is released?

dang mixups


when gf clicked
forever
  wait until <key [a] is pressed>
  move [-10] steps
  repeat until <>
    switch to costume [costume5]
  end
end

Offline

 

#4 2012-07-10 12:06:09

SciTecCf
Scratcher
Registered: 2011-11-23
Posts: 1000+

Re: How to sense when a button is released?

Just do this:

forever
 if <key [a v] pressed?>
  move (-1) steps
  switch to costume [running v]
 else
  switch to costume [standing v]
 end
end

Last edited by SciTecCf (2012-07-10 12:07:39)


http://bit.ly/LCZEJRhttp://bit.ly/LSONcOhttp://bit.ly/LF3vIc
http://trinary.site40.net/images/scratchrank.php?username=SciTecCf&amp;display=small

Offline

 

#5 2012-07-10 12:12:41

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: How to sense when a button is released?

^^ Yeah, that'll work fine.  The "wait until" blocks will stop your script until the condition is met.

Offline

 

Board footer