Antwort auf: Eigener Lautstärkeregler

Startseite Foren Deutsches LiveCode-Forum Eigener Lautstärkeregler Antwort auf: Eigener Lautstärkeregler

#18971
Klaus Major
Administrator

    Bitte schön:

    on mousemove x,y
       
       ## Nur ausführen, wenn Maus "down" ist!
       if darfziehen then
          switch
             ## Wir sind schon unten, also bei 0 angekommen
             case y < the top of grc "rampe_vertikal" + tAusgleich
                set the loc of me to item 1 of the loc of me, (the top of grc "rampe_vertikal")
                put 0 into neuelautstärke
                break
                
                ## Wir sind oben, also bei 100 angekommen
             case y > the bottom of grc "rampe_vertikal"
                set the loc of me to item 1 of the loc of me, the bottom of grc "rampe_vertikal" - tAusgleich
                put 100 intoneuelautstärke
                break
                
                ## Irgendwo zwischen 0 und 100
                ## Ein einfacher Dreisatz!
             default
                set the loc of me to item 1 of the loc of me, y - tAusgleich
                put round((y - the top of grc "rampe_vertikal")/the height of grc "rampe_vertikal"*maxValue) into neuelautstärke
                break
          end switch
          set the playloudness to neuelautstärke
       end if
    end mousemove

    Wichtig, versuche, das Skript zu verstehen, vielleicht zunächst einmal nur den Unterschied zum Skript mit dem Feld „volume“!

    Und dann die eigentliche Logik mit der dazugehörigen Mathematik/Arithemtik. Ist ätzend, geht aber nicht ohne. 😀

    Bei Fragen mach ich gerne den Erklärbär!