Result.js 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // Learn cc.Class:
  2. // - https://docs.cocos.com/creator/manual/en/scripting/class.html
  3. // Learn Attribute:
  4. // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
  5. // Learn life-cycle callbacks:
  6. // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
  7. cc.Class({
  8. extends: require("BaseItemConstroller"),
  9. properties: {
  10. },
  11. // LIFE-CYCLE CALLBACKS:
  12. onLoad() {
  13. this._super();
  14. this.init();
  15. this.game = cc.find("Canvas/Game");
  16. this.GameMode._gamestart = false;
  17. },
  18. start() {
  19. //this.interface_Against = cc.find("Canvas/Interface_Against");
  20. this.interface_info = cc.find("Canvas/Interface_Info").getComponent('Interface_Info');
  21. },
  22. btn_touch(event) {
  23. cc.audioEngine.playEffect(this.UiController.audioArr[0]);
  24. this.UiController.back_btn.active = false;
  25. this.node.parent.removeAllChildren();
  26. if (event.target.name == "Btn_Back") {
  27. console.log("回到主界面");
  28. this.UiController.Panel_Botton.active = true;
  29. this.Interface_Node.removeAllChildren();
  30. // this.interface_Against.active = true;
  31. if (this.GameState.gameresult) {
  32. console.log("获取箱子");
  33. this.interface_info.creatorgird();
  34. this.GameState.gameresult = false;
  35. }
  36. this.UiController.change_interface(this.UiController.interfacaArr, 0);
  37. }
  38. if (event.target.name == "Btn_LoadGame") {
  39. console.log("重启游戏");
  40. this.Interface_Node.removeAllChildren();
  41. this.game.removeAllChildren();
  42. this.UiController.actions();
  43. //var self = this;
  44. if (this.GameState.gameresult) {
  45. this.interface_info.creatorgird();
  46. this.GameState.gameresult = false;
  47. this.GameState._currPass--;
  48. }
  49. this.game.addChild(cc.instantiate(this.UiController.passArr[this.GameState._currPass]));
  50. // cc.resources.loadDir("prefab/Pass", (err, prefabs) => {
  51. // var interfacegame = cc.instantiate(prefabs[self.GameState._currPass]);
  52. // self.game.addChild(interfacegame);
  53. // });
  54. }
  55. if (event.target.name == "Btn_Box") {
  56. // 加载 Prefab
  57. cc.loader.loadRes("prefab/Result/interface_Box", (err, prefab) => {
  58. cc.find("Canvas/PanelResult").addChild(cc.instantiate(prefab));
  59. });
  60. }
  61. },
  62. // update (dt) {},
  63. init() {
  64. this.UiController = cc.find("Canvas/UiController").getComponent('UiController');
  65. this.Interface_Node = cc.find("Canvas/Interface_Node");
  66. this.GameState = cc.find("GameStates").getComponent("GameStates");
  67. this.GameMode = cc.find("GameMode").getComponent("GameMode");
  68. },
  69. });