cocos 滑动条调节音量

local function sliderEvent(sender, eventType)

-- 事件

if eventType == ccui.SliderEventType.percentChanged then 
            local slider1 = self.mbg:getChildByTag(1)
            local percent = slider1:getPercent()
            cc.UserDefault:getInstance():getBoolForKey("soundable", true)
       cc.UserDefault:getInstance():getIntegerForKey("soundvalue",percent)
            print("音效:" .. percent)
--            AudioEngine.setEffectsVolume(GlobalUserItem.nSound / percent)
            AudioEngine.setEffectsVolume(percent / 100.00)
        end

end

    local slider1 = ccui.Slider:create()
    slider1:setTag(self.CBT_SOUND)

    slider1:setTouchEnabled(true)

    slider1:loadBarTexture("Option/res_scene_room_bank_slider_back.png")  //背景阴影图片 
    slider1:loadSlidBallTextures("Option/res_scene_room_bank_btn_slider_1.png", "Option/res_scene_room_bank_btn_slider_2.png", "") //第一张是点击图片 ,第二张是点击后图片
    slider1:loadProgressBarTexture("Option/res_scene_room_bank_process_back.png")//滑动图片
    slider1:setPosition(cc.p(1080,420))
    slider1:setPercent(52)
    slider1:addEventListenerSlider(sliderEvent)
    self.mbg:addChild(slider1)

你可能感兴趣的:(cocos 滑动条调节音量)