Antwort auf: Eigener Lautstärkeregler

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

#19164
akrages
Teilnehmer

    Die Lese ich.
    Hab nur aus lauter Verzweiflung dein tLautstärke mal probehalber wieder in sBackground geändert, weil es ja im mouseMove noch so angegeben ist/war, (wurde von mir jetzt auch in tLautstärke geändert) und auch bisher bei mir immer so geheißen hat.
    Und ja, ich weiß, dass ich in der IDE nur einen Sound zur selben Zeit abspielen kann.
    Es spielt ja auch sonst keine zweiter Sound.

    Hier nun nochmal das geamte Script vom „SliderC4“

    local topValue,tScaleFactor,Bstop,Tstop,xLoc,cY,canMove,
    
    on mouseDown
       # Geben Sie Ihren Startwert (oben) ein
       put 100 into topValue
       # FÜGEN SIE IHREN ENDWERT (UNTEN) EIN
       put 1 into bottomValue
       
       # ERHALTEN SIE DEN OFFSET DES KLICKPUNKTES UND DES ZENTRUMS DES BTN
       # Dies verhindert, dass der BTN springt, wenn Sie mit dem Ziehen beginnen
       put (the mouseV - item 2 of the loc of me) into cY
       
       # Die Zahl, die am Ende der nächsten 3 Zeilen addiert oder subtrahiert wird
       # dient dazu, die Position des Schiebereglers so zu ändern, dass er an der gewünschten Stelle stoppt
       put (the bottom of image "Vsliderbar4")-(the height of me/2)+cY +7 into Bstop
       put (the top of image "Vsliderbar4")+(the height of me/2)+cY -27 into Tstop
       put item 1 of the loc of image "Vsliderbar4" +9 into xLoc
       put (bottomValue-topValue)/(Bstop-Tstop) into tScaleFactor
       put true into canMove
       
       ## sBackground ist keine LOKALE Variable, daher hier noch nicht bekannt 
       ## und es wird somit einen ERROR geben!
       ## Daher:
       put fld "theValue_v4" into tLautstärke
       ## Sofern ich Dich richtig verstanden habe.
       
       ## Verschachtelte IF THEN vermeiden
       if the environment <> "mobile" then
          set the playloudness to tLautstärke
          
          ## Auf dem Desktop oder in der IDE sind wir jetzt fertig!
          exit mousedown
       end if
       
       ## Initialisierung des Sounds:
       put (specialFolderPath("resources") & "/sound/background.wav") into tPath
       put "background" into tChannelName
       put "looping" into tType
       
       ## Warum nicht 0 nehmen, wenn bei 1 ja noch etas zu hören ist?
       if fld "theValue_v4" > 0 then
          
          ## Nur starten, wenn er nicht schon läuft:
          if mobileSoundChannelStatus("background") <> "playing" then
             mobilePlaySoundOnChannel tPath, tChannelName, tType
          end if
       else
          mobileStopSoundOnChannel tPath, tChannelName, tType
       end if
    end mouseDown
    
    on mouseMove x,y
       if not canMove then exit mouseMove
       put min(Bstop,max(Tstop,y)) into yLoc
       set loc of me to xLoc,yLoc-cY
       # Möglicherweise müssen Sie folgende Werte hinzufügen: xLoc und yLoc
       #, um den Wert fld an der gewünschten Stelle zu positionieren
       set the loc of fld "theValue_v4" to xLoc-40,yLoc-cY+10
       # Die folgende Zeile berechnet den Wert, den Sie möchten
       # wird auch für die tatsächliche Funktion des Schiebereglers verwendet
       put round((yLoc-Tstop)*tScaleFactor)+topValue into fld "theValue_v4"
       put "theValue_v4" into tLautstärke ##diese Zeile hinzugefügt
       ##if the environment = "mobile" then
          #### Der Channel Name in Anführungszeichen, die Variable noiseOne aber nicht!
          ##mobileSetSoundChannelVolume "background", sBackground ##diese Zeile hinzugefügt
       ##else
          ##put fld "theValue_v4" into tLautstärke
          ##set the playloudness to tLautstärke ##sBackground
       ##end if
    end mouseMove
    
    on mouseUp
       put false into canMove
       ##if fld "theValue_v4" <= 2  then
          ##stop playing audioClip "background.wav"
       ##else
          ####if fld "theValue_v4" >= 3  then
          ##play audioClip "background.wav" sBackground
       ##end if
       ####end if
    end mouseUp
    
    on mouseRelease
       mouseUp
    end mouseRelease