GameTip.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. var ZYGameTool = require('GameTool');
  2. var GameTipLayer = cc.Class({
  3. extends: cc.Component,
  4. properties: {
  5. btn: {
  6. title: "按钮",
  7. type: cc.Node,
  8. default:[],
  9. },
  10. btnCallFunc: null,
  11. coinNumbers: null,
  12. },
  13. onLoad() {
  14. console.log("into GameTip");
  15. this.coinNumbers = [10,15,25,35, 40];
  16. this.node.on(cc.Node.EventType.TOUCH_START, this.touchBegin.bind(this), this);
  17. if (!Module.GameTipLayer) Module.GameTipLayer = this;
  18. this.btn[0].on('click', function (event) {
  19. this.node.destroy();
  20. Module.GameTipLayer = null;
  21. }.bind(this));
  22. this.btn[1].on('click', function (event) {
  23. var num = this.coinNumbers[zy.randNum(0,4)];
  24. this.openVideo(num);
  25. }.bind(this));
  26. this.btn[1].runAction(cc.repeatForever(cc.sequence(cc.scaleTo(0.8, 1.15), cc.scaleTo(1, 0.8))));
  27. },
  28. start() {
  29. },
  30. openVideo: function(num){
  31. ZYGameTool.getInstance().OpenAd("home_prop", "video",
  32. function () {
  33. // this.coinAction(num);
  34. coinNum += num;
  35. ZYGameTool.getInstance().setIntegerForKey(localDataItem.coinNum, coinNum);
  36. if(this.btnCallFunc) this.btnCallFunc(num);
  37. this.node.destroy();
  38. console.log("---debug---成功---");
  39. }.bind(this),
  40. function () {
  41. if(this.btnCallFunc) this.btnCallFunc(0);
  42. console.log("---debug---失败---");
  43. }.bind(this),
  44. )
  45. },
  46. call: function (func) {
  47. this.btnCallFunc = func;
  48. },
  49. touchBegin: function (touch, event) {
  50. // this.node.destroy();
  51. },
  52. // update (dt) {},
  53. });