(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff) 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 -90° (pointing left) to 180° (pointing down). The default value for the direction is 90° (pointing right).

Whether the sprite is actually 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

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.

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:

— The stage monitor and reporter block of the direction value

— Changes the direction by a certain amount

— Sets the direction of a sprite

— Changes the direction to point at either another sprite or the mouse pointer

— Changes the direction by -180° when a sprite is touching the edge

— Moves in the current direction

— A block that reports the value of any sprite's X Position, Y Position, Direction, Costume/Background number, Size, Volume, Variables

## 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 round really fast, changing the costume, and then slowing it down)