Scratch for Java

Sprite::setX()

Sets the x coordinate of the sprite.

Examples

import org.openpatch.scratch.Sprite;
import org.openpatch.scratch.Stage;
 
public class SpriteSetX {
  public SpriteSetX() {
    Stage myStage = new Stage(600, 240);
    Sprite mySprite = new Sprite("slime", "assets/slime.png");
    myStage.add(mySprite);
    myStage.wait(2000);
    mySprite.setX(50);
    myStage.wait(2000);
    myStage.exit();
  }
 
  public static void main(String[] args) {
    new SpriteSetX();
  }
}
 

View on GitHub

Syntax

Java

.setX(value)

Scratch

set x to ()

Parameters

Name Data Type Description
value float The x coordinate of the sprite.

Return

void

setX()