Benutzer-Werkzeuge

Webseiten-Werkzeuge


api:documentation:spiele:sound

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Nächste Überarbeitung
Vorhergehende Überarbeitung
api:documentation:spiele:sound [2021/01/16 22:22] – angelegt Martin Pabstapi:documentation:spiele:sound [2021/12/29 11:29] (aktuell) – Externe Bearbeitung 127.0.0.1
Zeile 7: Zeile 7:
 </WRAP> </WRAP>
  
 +===== Beispiel ===== 
 +Starte das Programm und drücke die Tasten a, b oder c!
  
 <HTML> <HTML>
  
-<div class="java-online" style="height: 400px; width: 80%" data-java-online="{'withBottomPanel': false, 'id': 'Sound'}">+<div class="java-online" style="height: 500px; width: 80%" data-java-online="{'withBottomPanel': false, 'id': 'Sound'}">
  
 <script type="text/plain" title="Sound.java"> <script type="text/plain" title="Sound.java">
-for(int i = 0; i < 10; i++) { +SystemTools.addKeyListener(new SoundPlayer()); 
-    +while(true);
-   DragDropRechteck r = new DragDropRechteck(70 * i, 300, 50, 50); +
-   r.setFillColor(Color.randomColor(50));+
  
-} 
  
-while(true); +class SoundPlayer implements KeyListener {
- +
-class DragDropRechteck extends Rectangle {+
        
-   boolean mouseDown = false; +  public void onKeyTyped(String key) { 
-   double mouseXLastTime = 0; +     switch(key) { 
-   double mouseYLastTime = 0; +         case "a 
- +               Sound.playSound(Sound.laser_shoot); 
- +            break
-   public void onMouseEnter(double x, double y) { +         case "b" :  
-      tint("#808080"); +               Sound.playSound(Sound.nearby_explosion); 
-   } +            break; 
- +         case "c" 
-   public void onMouseLeave(double x, double y) { +               Sound.playSound(Sound.pong_d); 
-      tint("#ffffff"); +            break
-   } +            default :  
- +              
-   public void onMouseDown(double x, double y, int key+            
-      mouseXLastTime = x+   }
-      mouseYLastTime = y+
-      mouseDown = true; +
-      // Ab jetzt soll onMouseMove auch aufgerufen werden, wenn sich der +
-      // Mauszeiger außerhalb des Objektes befindet+
-      startTrackingEveryMouseMovement(); +
-   } +
- +
-   public void onMouseMove(double x, double y) { +
-      if(mouseDown) {  +
-         move(x - mouseXLastTime, y - mouseYLastTime); +
-         mouseXLastTime = x+
-         mouseYLastTime = y; +
-      } +
-   +
- +
-   public void onMouseUp(double x, double y, int key) { +
-      mouseDown = false; +
-      stopTrackingEveryMouseMovement(); +
-   }+
  
 } }
api/documentation/spiele/sound.1610832172.txt.gz · Zuletzt geändert: 2021/12/29 11:29 (Externe Bearbeitung)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki