Settings.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. cc.Class({
  2. extends: cc.Component,
  3. properties: {
  4. _isOpen: true,
  5. },
  6. // LIFE-CYCLE CALLBACKS:
  7. // onLoad () {},
  8. start() {
  9. },
  10. onEnable() {
  11. this.qiyong = this.node.getChildByName("启用");
  12. this.buqiyong = this.node.getChildByName("不启用");
  13. if (OnOff == true) {
  14. this.qiyong.active = true;
  15. this.buqiyong.active = false;
  16. this._isOpen = true;
  17. } else {
  18. this.qiyong.active = false;
  19. this.buqiyong.active = true;
  20. this._isOpen = false;
  21. }
  22. },
  23. 启用(event) {
  24. event.target.active = false;
  25. this._isOpen = false;
  26. this.buqiyong.active = true;
  27. },
  28. 不启用(event) {
  29. event.target.active = false;
  30. this._isOpen = true;
  31. this.qiyong.active = true;
  32. },
  33. 取消() {
  34. if (this._isOpen == true) {
  35. this.qiyong.active = true;
  36. this.buqiyong.active = false;
  37. } else {
  38. this.qiyong.active = false;
  39. this.buqiyong.active = true;
  40. }
  41. this.关闭();
  42. },
  43. 保存() {
  44. OnOff = this._isOpen;
  45. this.关闭();
  46. },
  47. 关闭() {
  48. this.node.active = false;
  49. cc.director.resume();
  50. },
  51. // update (dt) {},
  52. });