Scratch Cat changing directions (and moving, to see differences) 36 times, changing direction by 10 degrees each time.

A sprite's direction value controls how much a sprite is rotated. It is measured in degrees (°) and ranges from -180° to 180° (both pointing down). The default value for the direction is 90° (pointing right).

Whether the sprite is actually visually rotated or not is determined by the sprite's rotation style.

Depending on the direction a sprite is pointing in, the Move () Steps block will move the sprite differently. However, the Change X by () and Change Y by () blocks are not affected by the direction of a sprite.

Directions

The direction system Scratch uses.

Scratch uses an angle measurement that is similar to degrees, with the addition of negative values, like polar coordinates. "0" represents "up". Every degree added corresponds to a one degree turn clockwise by the sprite. So a direction of 90 means a sprite turns 90 degrees (a quarter turn) after pointing straight up and will thus point right.

Note Note: A sprite's default direction value is 90, which actually represents no rotation.

Negative degree measures simply mean rotation counter-clockwise rather than clockwise. So -90 is left and -180 is down, just like +180.

This table shows some common values and their directions:

Degrees Direction
-360, 0, 360 Up
-270, 90 Right
-180, 180 Down
-90, 270 Left

Finally, when the direction is greater than 360°, the sprite points in the direction, minus 360°. So 400° is analogous to 400-360=40°, and 720° = 360° = 0°. This can be mimicked by the code below.

The expression that returns the direction (subtracting the 360 if the number is too large) is this:

((((180) + (x)) mod (360)) - (180))

Related Blocks

The following blocks can be used in conjunction with this value:

Example Uses

This value can be used in a number of ways:

  • Spinning an object in a game
  • Making a sprite point at the mouse pointer or another sprite
  • Can be used to give the illusion that a sprite is turning into something else (i.e. spinning it around really fast, changing the costume, and then slowing it down)
  • Making a pong game, that when the ball touches the paddle, it turns -180 degrees

See Also

Cookies help us deliver our services. By using our services, you agree to our use of cookies.