api:documentation:spiele:sound
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
api:documentation:spiele:sound [2021/01/16 22:22] – angelegt Martin Pabst | api:documentation:spiele:sound [2021/12/29 11:29] (aktuell) – Externe Bearbeitung 127.0.0.1 | ||
---|---|---|---|
Zeile 7: | Zeile 7: | ||
</ | </ | ||
+ | ===== Beispiel ===== | ||
+ | Starte das Programm und drücke die Tasten a, b oder c! | ||
< | < | ||
- | <div class=" | + | <div class=" |
<script type=" | <script type=" | ||
- | for(int i = 0; i < 10; i++) { | + | SystemTools.addKeyListener(new SoundPlayer()); |
- | + | while(true); | |
- | | + | |
- | r.setFillColor(Color.randomColor(50)); | + | |
- | } | ||
- | while(true); | + | class SoundPlayer implements KeyListener |
- | + | ||
- | class DragDropRechteck extends Rectangle | + | |
- | | + | public void onKeyTyped(String key) { |
- | | + | |
- | | + | case "a" |
- | + | Sound.playSound(Sound.laser_shoot); | |
- | + | break; | |
- | public void onMouseEnter(double x, double y) { | + | case " |
- | tint("# | + | Sound.playSound(Sound.nearby_explosion); |
- | } | + | |
- | + | case " | |
- | | + | Sound.playSound(Sound.pong_d); |
- | tint("#ffffff"); | + | break; |
- | } | + | |
- | + | | |
- | | + | } |
- | mouseXLastTime = x; | + | } |
- | | + | |
- | | + | |
- | // Ab jetzt soll onMouseMove auch aufgerufen werden, wenn sich der | + | |
- | // Mauszeiger außerhalb des Objektes befindet: | + | |
- | | + | |
- | } | + | |
- | + | ||
- | public void onMouseMove(double x, double y) { | + | |
- | if(mouseDown) { | + | |
- | move(x - mouseXLastTime, | + | |
- | mouseXLastTime = x; | + | |
- | mouseYLastTime = y; | + | |
- | } | + | |
- | | + | |
- | + | ||
- | | + | |
- | mouseDown = false; | + | |
- | stopTrackingEveryMouseMovement(); | + | |
- | } | + | |
} | } |
api/documentation/spiele/sound.1610832172.txt.gz · Zuletzt geändert: 2021/12/29 11:29 (Externe Bearbeitung)