1、创建控件Slider命名Slider_Horizontal
2、在控件Slider_Horizontal创建一个Sprite当做背景和创建一个Button命名为Handle当做滑块。
3、控件Slider_Horizontal关联Button
4、创建脚本SliderCtrl.js并且控件中关联本脚本
properties: {
music: cc.AudioSource,
slider_h: cc.Slider,
},
_updateMusicVolume (progress) {
this.music.volume = progress;
},
onSliderHEvent (sender, eventType) {
this._updateMusicVolume(sender.progress);
}