Scratch für Java

Sprite::distanceToMousePointer()

Gibt die Distanz zum Mauszeiger zurück.

Beispiele

import org.openpatch.scratch.*;
 
public class SpriteDistanceToMousePointer {
  public SpriteDistanceToMousePointer() {
    Stage myStage = new Stage(600, 240);
 
    Sprite gamma = new Sprite("gamma", "assets/gamma_purple_badge.png");
    gamma.setPosition(0, 50);
    myStage.add(gamma);
 
    while (myStage.getTimer().forMillis(3000)) {
      gamma.changeX(5);
      myStage.display("Distance: " + gamma.distanceToMousePointer());
      myStage.wait(100);
    }
    myStage.exit();
  }
 
  public static void main(String[] args) {
    new SpriteDistanceToMousePointer();
  }
}
 

Auf GitHub anschauen

Syntax

Java

.distanceToMousePointer()

Scratch

distance to [mouse-pointer v]?

Rückgabe

float

distanceToMousePointer()