Scratch for Java

Sprite::setRotationCenter()

Sets the point of the costume the sprite turns around - Scratch's rotation center. It is also the point that sits at the sprite's position, so it is where the pen draws from and what goTo puts in place.

The point is given in the costume's own pixels, counted from its top left corner, the same way as setHitbox(double...): a sword whose hilt is 12 pixels from the left and 60 from the top swings around the hilt with setRotationCenter(12, 60). It grows and shrinks with the sprite's size and holds for every costume of the sprite. Without it, a sprite turns around the middle of its costume.

this.addCostume("hand", "assets/clock-hand.png");
 this.setRotationCenter(8, 100); // the end of the hand

Examples

View on GitHub

Syntax

Java

.setRotationCenter(x, y)

Parameters

Name Data Type Description
x double the x-coordinate in the costume, from its left edge
y double the y-coordinate in the costume, from its top edge

Return

void

setRotationCenter()

Create Shareable URL

Select Sections