To make your character (sprite) rotate in Scratch, the most common and versatile method is to use the turn
block within a forever
loop. This allows for continuous rotation, either in place or as part of a movement path.
Basic Continuous Rotation
For a sprite to spin constantly, you'll need two core blocks:
turn ↻ (degrees) degrees
: This block changes your sprite's direction by a specified number of degrees.forever
: This control block ensures that any code inside it repeats indefinitely.
To make your character rotate continuously and smoothly, place a turn
block, such as turn ↻ 1 degrees
, inside a forever
loop. This will make your sprite appear to spin. If you do not add any move
blocks, your character will rotate directly in its current position, creating an effect of spinning in place. Using a small degree value, like 1 or 2, ensures a smooth visual rotation.
How to Implement Continuous Rotation:
- Start Event: Drag a
when green flag clicked
block from the "Events" category. - Loop: Attach a
forever
block from the "Control" category below thewhen green flag clicked
block. - Rotation: Place a
turn ↻ 1 degrees
block (orturn ↺ 1 degrees
for counter-clockwise) from the "Motion" category inside theforever
loop. You can adjust the1
to any number; larger numbers make it spin faster.
Example Code:
when green flag clicked
forever
turn ↻ 1 degrees
This simple script will make your sprite continuously rotate one degree clockwise every frame, resulting in a smooth, ongoing spin.
Different Ways to Control Character Rotation
Scratch offers several blocks to manage your sprite's orientation, giving you precise control over its rotation.
Rotating by a Specific Angle
If you want your character to turn only once by a certain amount, simply use the turn
block without a forever
loop.
turn ↻ 15 degrees
: Rotates the sprite clockwise by 15 degrees.turn ↺ 15 degrees
: Rotates the sprite counter-clockwise by 15 degrees.
When to Use: Ideal for actions like a character turning to face a new direction after an event, or an object rotating a set amount each time it's clicked.
Pointing in a Fixed Direction
The point in direction (90)
block allows you to instantly orient your sprite to a specific angle.
point in direction 90
: Points the sprite to the right.point in direction -90
: Points the sprite to the left.point in direction 0
: Points the sprite upwards.point in direction 180
: Points the sprite downwards.
When to Use: Useful for resetting a character's orientation at the start of a game or ensuring it faces a specific cardinal direction.
Pointing Towards Another Sprite or Mouse Pointer
The point towards (mouse-pointer)
block makes your sprite face a particular target, whether it's the mouse cursor or another sprite on the stage.
point towards [mouse-pointer v]
: The sprite will rotate to face the current position of the mouse pointer.point towards [Sprite2 v]
: The sprite will rotate to face the center of "Sprite2".
When to Use: Perfect for creating characters that follow the mouse, shooting games where a turret aims at an enemy, or character interactions where one sprite looks at another.
Understanding Rotation Styles
Scratch provides a crucial block called set rotation style
that dictates how your sprite visually rotates when its direction changes. You can find this block in the "Motion" category.
Rotation Style | Description | Visual Effect |
---|---|---|
all around |
Allows the sprite to rotate through all 360 degrees. | The sprite spins freely, showing all its sides as its direction changes. |
left-right |
The sprite only faces left or right. If its direction is up or down, it will still appear to face left or right, effectively flipping horizontally. | The sprite maintains an upright appearance but flips horizontally when its direction crosses the vertical axis. |
don't rotate |
The sprite's visual appearance never changes, regardless of its direction. | The sprite always looks the same, even if its internal direction property has changed. |
When to Use:
all around
: Best for spaceships, wheels, or characters that can genuinely spin completely.left-right
: Ideal for characters that typically walk on a flat surface and you only want them to face left or right, not tilt on their side.don't rotate
: Useful for backgrounds or elements where you want to change their internal direction for calculation purposes (e.g., shooting a projectile) but don't want the visual element itself to turn.
You typically set the rotation style once at the beginning of your project using the when green flag clicked
block.
Practical Tips for Smooth Rotations
- Small Steps for Smoothness: When using
turn
in aforever
loop, smaller degree values (like 1 or 2) result in much smoother visual rotation than larger jumps (e.g., 15 or 30 degrees). - Resetting Direction: It's good practice to start your sprite facing a specific direction using
point in direction 90
(right) orpoint in direction 0
(up) when the green flag is clicked, especially if you're experimenting with different rotations. - Combining with Movement: To make a sprite move in a circle, combine a
move (steps) steps
block with aturn (degrees) degrees
block inside aforever
loop. The sprite will turn slightly, then move forward, and repeat, creating a curved path. For more details on movement, refer to Scratch's official tutorials.
By understanding these blocks and rotation styles, you can effectively control how your characters move and orient themselves in your Scratch projects, bringing your creations to life!