Sprite::whenMouseMoved(x, y)
Die Methode wird ausgeführt, wenn sich der Mauszeiger bewegt.
Beispiele

import org.openpatch.scratch.Sprite;
import org.openpatch.scratch.Stage;
public class SpriteWhenMouseMoved {
class CustomSprite extends Sprite {
public CustomSprite() {
this.addCostume("zeta", "assets/zeta_green_badge.png");
this.addCostume("gamma", "assets/gamma_purple_badge.png");
}
@Override
public void whenMouseMoved(double x, double y) {
this.setPosition(x, y);
}
}
public SpriteWhenMouseMoved() {
Stage myStage = new Stage(600, 240);
myStage.add(new CustomSprite());
while (myStage.getTimer().forMillis(3000)) {}
myStage.exit();
}
public static void main(String[] args) {
new SpriteWhenMouseMoved();
}
}
Syntax
Java
void whenMouseMoved(x, y)
Scratch
when mouse moved :: hat
Parameter
Name | Datentyp | Beschreibung |
---|---|---|
x | float | Die x-Koordinate des Mauszeigers. |
y | float | Die y-Kooridnate des Mauszeigers. |
Rückgabe
void