ZY_GameFaildLayer.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Learn cc.Class:
  2. // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/class.html
  3. // - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/class.html
  4. // Learn Attribute:
  5. // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
  6. // - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/reference/attributes.html
  7. // Learn life-cycle callbacks:
  8. // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
  9. // - [English] https://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
  10. var GameFaild = cc.Class({
  11. extends: cc.Component,
  12. properties: {
  13. videoBtn: cc.Node,
  14. jumpBtn: cc.Node,
  15. btnCallFunc: null,
  16. },
  17. // LIFE-CYCLE CALLBACKS:
  18. onLoad() {
  19. this.node.on(cc.Node.EventType.TOUCH_START, this.touchBegin.bind(this), this);
  20. if (!Module.GameFaildLayer) Module.GameFaildLayer = this;
  21. this.videoBtn.on('click', function (event) {
  22. this.videoClick();
  23. }.bind(this));
  24. this.jumpBtn.on('click', function (event) {
  25. this.jumpClick();
  26. }.bind(this));
  27. },
  28. start() {
  29. },
  30. videoClick: function () {
  31. if(this.btnCallFunc) this.btnCallFunc(true);
  32. Module.GameFaildLayer =null;
  33. this.node.destroy();
  34. },
  35. jumpClick: function () {
  36. if(this.btnCallFunc) this.btnCallFunc(false);
  37. Module.GameFaildLayer =null;
  38. this.node.destroy();
  39. cc.director.loadScene("homeScene");
  40. },
  41. call: function (func) {
  42. this.btnCallFunc = func;
  43. },
  44. touchBegin: function (touch, event) {
  45. },
  46. // update (dt) {},
  47. });