ZY_GameFaildLayer.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. var ZYGameTool = require('GameTool');
  2. var GameFaild = cc.Class({
  3. extends: cc.Component,
  4. properties: {
  5. videoBtn: cc.Node,
  6. jumpBtn: cc.Node,
  7. btnCallFunc: null,
  8. numNode:cc.Node,
  9. number:8,
  10. },
  11. // LIFE-CYCLE CALLBACKS:
  12. onLoad() {
  13. console.log("into GameFaild");
  14. this.number = 8;
  15. this.schedule(this.countTime, 1);
  16. this.node.on(cc.Node.EventType.TOUCH_START, this.touchBegin.bind(this), this);
  17. if (!Module.GameFaildLayer) Module.GameFaildLayer = this;
  18. this.videoBtn.on('click', function (event) {
  19. this.videoClick();
  20. }.bind(this));
  21. this.jumpBtn.on('click', function (event) {
  22. this.jumpClick();
  23. }.bind(this));
  24. ZYGameTool.getInstance().OpenAd("banner", "banner");
  25. },
  26. start() {
  27. },
  28. countTime: function (){
  29. --this.number;
  30. this.numNode.getComponent(cc.Label).string = this.number;
  31. if (this.number == 0) {
  32. this.jumpClick();
  33. }
  34. if (this.number == 5){
  35. this.jumpBtn.active =true;
  36. }
  37. },
  38. videoClick: function () {
  39. this.unschedule(this.countTime);
  40. ZYGameTool.getInstance().OpenAd("home_lqjb", "video",
  41. function () {
  42. console.log("---debug---成功---");
  43. if(this.btnCallFunc) this.btnCallFunc(true);
  44. Module.GameFaildLayer =null;
  45. this.node.destroy();
  46. }.bind(this),
  47. function () {
  48. this.schedule(this.countTime, 1);
  49. // if(this.btnCallFunc) this.btnCallFunc(false);
  50. // Module.GameFaildLayer =null;
  51. // if (Module.GameManager) Module.GameManager.clearData();
  52. // gameLocalData.clear();
  53. // this.node.destroy();
  54. // cc.director.loadScene("homeScene");
  55. // console.log("---debug---失败---");
  56. }.bind(this),
  57. )
  58. },
  59. jumpClick: function () {
  60. if(this.btnCallFunc) this.btnCallFunc(false);
  61. if (Module.GameManager) Module.GameManager.clearData();
  62. gameLocalData.clear();
  63. Module.GameFaildLayer =null;
  64. this.node.destroy();
  65. cc.director.loadScene("homeScene");
  66. },
  67. call: function (func) {
  68. this.btnCallFunc = func;
  69. },
  70. touchBegin: function (touch, event) {
  71. },
  72. // update (dt) {},
  73. });