Pen::setPosition()
Set the position if the pen is down.
Examples
import org.openpatch.scratch.Stage;
import org.openpatch.scratch.Pen;
public class PenSetPosition {
public PenSetPosition() {
Stage myStage = new Stage(600, 240);
Pen myPen = new Pen();
myStage.add(myPen);
myPen.setSize(10);
while (myStage.getTimer().forMillis(3000)) {
myPen.changeColor(10);
myPen.down();
myPen.setPosition(myStage.pickRandom(-myStage.getWidth() / 2, myStage.getWidth() / 2), 45);
myPen.up();
myStage.wait(200);
}
myStage.exit();
}
public static void main(String[] args) {
new PenSetPosition();
}
}
Syntax
Java
.setPosition(x, y)
.setPosition(v)
Parameters
| Name | Data Type | Description |
|---|---|---|
| x | double | x coordinate |
| y | double | y coordinate |
| v | Vector2 | the Vector2 object containing the new x and y coordinates |
Return
void