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

#1 2012-07-11 01:43:34

Normo
New Scratcher
Registered: 2012-07-08
Posts: 11

Moving a Sprite

I'm building a small coin collecting game, where the player collects coins while stomping on enemies. I've made my main sprite some idle animations (for when he is not moving). I have also made two scripts for moving left and right. So far, when I presses D, the sprite moves to the right and stops the idle animations, which is fine. Although, when I press A, the sprite moves to the left and keeps his idle animations going.

Is there anyway to stop this? Here's a link to the project: www.scratch.mit.edu/projects/Normo/2667422

Offline

 

#2 2012-07-11 10:15:08

Wes64
Scratcher
Registered: 2011-08-19
Posts: 1000+

Re: Moving a Sprite

Its usually a good idea to put that all in one script.

when gf clicked
forever
if <key [left arrow v] pressed?>
go left
else
if <key [right arrow v] pressed?>
go right
else
be idle
end
end

Last edited by Wes64 (2012-07-11 10:15:16)


Experienced 2.0 Tester: Ask me questions!
Using Firefox 13.0, Flash plugin version 11.4.402.287, and Windows XP Professional.

Offline

 

#3 2012-07-11 12:06:43

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

Re: Moving a Sprite

^^ I personally don't like this script, because if both keys are pressed, the character will move left.

Offline

 

#4 2012-07-11 12:19:44

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

Re: Moving a Sprite

amcerbu wrote:

^^ I personally don't like this script, because if both keys are pressed, the character will move left.

Yeah.

when gf clicked
forever
 if <key [left arrow v] pressed?>
  change x by (-2)
 end
 if <key [right arrow v] pressed?>
  change x by (2)
 end
end
Test in presentation mode.  wink


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

Offline

 

Board footer