123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- cc.Class({
- extends: cc.Component,
- properties: {
- button: cc.Button,
- },
- // 存储数据:cc.sys.localStorage.setItem(“key”,”value”)
- // 获取数据:cc.sys.localStorage.getItem(“key”)
-
- // 移除数据:cc.sys.localStorage.removeItem(“key”)
-
- // 清除所有:cc.sys.localStorage.clear()
- // use this for initialization
- onLoad: function () {
- this.button.node.on('click', this.callback, this);
- console.log('yinyue',Global.NoSound );
- var self = this;
- if(Global.NoSound == false){
- cc.loader.loadRes('texture/声音开', cc.SpriteFrame, function (err, spriteFrame) {
- self.node.getChildByName('Label').getComponent(cc.Sprite).spriteFrame = spriteFrame;
- });
- }else{
- cc.loader.loadRes('texture/声音关', cc.SpriteFrame, function (err, spriteFrame) {
- self.node.getChildByName('Label').getComponent(cc.Sprite).spriteFrame = spriteFrame;
- });
- }
- },
- // called every frame
- update: function (dt) {
- },
- callback: function (event) {
- var self = this;
- if(Global.NoSound == false){
- cc.audioEngine.pauseAll();
- Global.NoSound = true;
- cc.loader.loadRes('texture/声音关', cc.SpriteFrame, function (err, spriteFrame) {
- self.node.getChildByName('Label').getComponent(cc.Sprite).spriteFrame = spriteFrame;
- });
- }else{
- Global.NoSound = false;
- Audio.playeffect('resources/audio/sound_click.mp3');
- cc.audioEngine.resumeAll();
- cc.loader.loadRes('texture/声音开', cc.SpriteFrame, function (err, spriteFrame) {
- self.node.getChildByName('Label').getComponent(cc.Sprite).spriteFrame = spriteFrame;
- });
- }
-
- //cc.find('Canvas/ChouseStyle').active = true;
- }
- });
|