lua有关网站http://blog.51cto.com/shahdza/1569003
复选框
local checkbox1=node:getChildByName("CheckBox_1")
music=userDefualt:getBoolForKey("yinyue1");
checkbox1:setSelected(music);
checkbox1:addEventListener(function ( sender,eventType)
-- 0==ccui.CheckBoxEventType.selected
-- 1==ccui.CheckBoxEventType.unselected
if eventType==0 then
cc.SimpleAudioEngine:getInstance():resumeMusic()
userDefualt:setBoolForKey("yinyue1",true);
userDefualt:flush();
slider:setEnabled(true );
print("点击")
elseif eventType==1 then
userDefualt:setBoolForKey("yinyue1",false);
userDefualt:flush();
slider:setEnabled(false );
cc.SimpleAudioEngine:getInstance():pauseMusic()
end
end)
手动滑块
用cocos2d studio拼
slider:setEnabled(music);
yinliang=userDefualt:getIntegerForKey("yinliang");
slider:setMaxPercent(10);
slider:setPercent(yinliang);
slider:addEventListener(function (sender,eventType)
if eventType==ccui.SliderEventType.percentChanged then
local voile=slider:getPercent();
self.volic=voile
cc.SimpleAudioEngine:getInstance():setMusicVolume(voile*0.1);
userDefualt:setIntegerForKey("yinliang",voile);
userDefualt:flush();