Scratch for Java

Sprite::isTouchingEdge()

Returns true if the hitbox is touching the edge.

Examples

import org.openpatch.scratch.*;

public class SpriteIsTouchingEdge {
  public SpriteIsTouchingEdge() {
    Stage myStage = new Stage(600, 240);
    Sprite mySprite = new Sprite("zeta", "assets/zeta_green_badge.png");
    mySprite.changeY(-10);
    mySprite.changeX(-80);
    myStage.add(mySprite);

    while (myStage.getTimer().forMillis(3000)) {
      mySprite.say("Is touching edge? " + mySprite.isTouchingEdge());
      mySprite.changeY(10);
      myStage.wait(200);
    }
    myStage.exit();
  }

  public static void main(String[] args) {
    new SpriteIsTouchingEdge();
  }
}

View on GitHub

Syntax

Java

.isTouchingEdge()

Scratch

Return

boolean