Scratch for Java

Sprite::getX()

Gets the x position of the sprite.

Examples

import org.openpatch.scratch.*;
 
public class SpriteGetX {
  public SpriteGetX() {
    Stage myStage = new Stage(600, 240);
    Sprite mySprite = new Sprite("zeta", "assets/zeta_green_badge.png");
    myStage.add(mySprite);
    mySprite.changeX(-80);
    mySprite.changeY(30);
    mySprite.say("X: " + mySprite.getX());
    myStage.wait(3000);
    myStage.exit();
  }
 
  public static void main(String[] args) {
    new SpriteGetX();
  }
}
 

View on GitHub

Syntax

Java

.getX()

Scratch

(x position)

Return

float

getX()