text: /****************************************************************************
   Cocos2d-html5 show case : Moon Warriors
  
   Copyright (c) 2011-2012 cocos2d-x.org
   Copyright (c) 2013-2014 Chukong Technologies Inc.
  
   http://www.cocos2d-x.org
  
   Permission is hereby granted, free of charge, to any person obtaining a copy
   of this software and associated documentation files (the "Software"), to deal
   in the Software without restriction, including without limitation the rights
   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
   copies of the Software, and to permit persons to whom the Software is
   furnished to do so, subject to the following conditions:
  
   The above copyright notice and this permission notice shall be included in
   all copies or substantial portions of the Software.
  
   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE
   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
   THE SOFTWARE.
  
   @Authors:
   Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada
   Effects animation: Hao Wu (吴昊)
   Quality Assurance: Sean Lin (林顺)
   ****************************************************************************/
  
  var SettingsLayer = cc.Layer.extend({
      ctor:function(){
          this._super();
          this.init();
      },
      init:function () {
          var sp = new cc.Sprite(res.loading_png);
          sp.anchorX = 0;
          sp.anchorY = 0;
          sp.scale = MW.SCALE;
          this.addChild(sp, 0, 1);
  
          var cacheImage = cc.textureCache.addImage(res.menuTitle_png);
          var title = new cc.Sprite(cacheImage, cc.rect(0, 0, 134, 39));
          title.x = winSize.width / 2;
          title.y = winSize.height - 120;
          this.addChild(title);
  
  
          cc.MenuItemFont.setFontName("Arial");
          cc.MenuItemFont.setFontSize(18);
          var title1 = new cc.MenuItemFont("Sound");
          title1.setEnabled(false);
          title1.setColor(cc.color(MW.FONTCOLOR));
  
          cc.MenuItemFont.setFontName("Arial");
          cc.MenuItemFont.setFontSize(26);
          var item1 = new cc.MenuItemToggle(
              new cc.MenuItemFont("On"),new cc.MenuItemFont("Off"));
          item1.setCallback(this.onSoundControl );
          item1.setColor(cc.color(MW.FONTCOLOR));
          var state = MW.SOUND ? 0 : 1;
          item1.setSelectedIndex(state);
  
          cc.MenuItemFont.setFontName("Arial");
          cc.MenuItemFont.setFontSize(18);
          var title2 = new cc.MenuItemFont("Mode");
          title2.setEnabled(false);
          title2.setColor(cc.color(MW.FONTCOLOR));
  
          cc.MenuItemFont.setFontName("Arial");
          cc.MenuItemFont.setFontSize(26);
          var item2 = new cc.MenuItemToggle(
              new cc.MenuItemFont("Easy"),
              new cc.MenuItemFont("Normal"),
              new cc.MenuItemFont("Hard"));
          item2.setColor(cc.color(MW.FONTCOLOR));
          item2.setCallback( this.onModeControl );
  
  
          cc.MenuItemFont.setFontName("Arial");
          cc.MenuItemFont.setFontSize(26);
          var label = new cc.LabelTTF("Go back", "Arial", 20);
          label.setColor(cc.color(MW.FONTCOLOR));
          var back = new cc.MenuItemLabel(label, this.onBackCallback);
          back.scale = 0.8;
  
          var menu = new cc.Menu(title1, title2, item1, item2, back);
          menu.alignItemsInColumns(2, 2, 1);
          this.addChild(menu);
  
          back.y -= 50;
  
          return true;
      },
      onBackCallback:function (pSender) {
          var scene = new cc.Scene();
          scene.addChild(new SysMenu());
  	    cc.director.runScene(new cc.TransitionFade(1.2, scene));
      },
      onSoundControl:function(){
          MW.SOUND = !MW.SOUND;
          var audioEngine = cc.audioEngine;
          if(MW.SOUND){
              audioEngine.playMusic(res.mainMainMusic_mp3);
          }
          else{
              audioEngine.stopMusic();
  	        audioEngine.stopAllEffects();
          }
      },
      onModeControl:function(){
      }
  });
  