Scratch for Java

Sprite::changeX()

Change the x position by a given amount.

Examples

import org.openpatch.scratch.*;
 
public class SpriteChangeX {
  public SpriteChangeX() {
    Stage myStage = new Stage(600, 240);
    Sprite mySprite = new Sprite("zeta", "assets/zeta_green_badge.png");
    myStage.add(mySprite);
 
    myStage.wait(2000);
    mySprite.changeX(100);
    myStage.wait(2000);
 
    myStage.exit();
  }
 
  public static void main(String[] args) {
    new SpriteChangeX();
  }
}
 

View on GitHub

Syntax

Java

.changeX(amount)

Scratch

change x by ()

Parameters

Name Data Type Description
amount float Changes the x position by the amount.

Return

void

changeX()