Cocos Creator音量調整スライダ使用

770 ワード

仲間たちは開発の過程で、音声スイッチを設置する機能に出会うと信じています.
それでは私は今日Cocos Creatorの公式ケースを調べて、書いたのは悪くないことに気づいたが、残念なことに1字の注釈がなく、私の理解のついでに注釈付きのコードを整理した.
くだらないことは言わないで、直接コードを引っ張ってください.
cc.Class({
    extends: cc.Component,

    properties: {
    //    AudioSource,          
   //  UI  Slider,
        music: cc.AudioSource,
        slider_h: cc.Slider,
    },

    onLoad () {
    //    Slider Progress,         
    //            
        this.slider_h.progress = 0.5;
        this._updateMusicVolume(this.slider_h.progress);
    },

    _updateMusicVolume (progress) {
        this.music.volume = progress;
    },

// Slider         
    onSliderHEvent (sender, eventType) {
        this._updateMusicVolume(sender.progress);
    }
});


さあ、簡単な音の調節で終わりました...