offline.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. cc.Class({
  2. extends: cc.Component,
  3. properties: {
  4. num1: cc.Label,
  5. num2: cc.Label,
  6. btn1: cc.Node,
  7. btn2: cc.Node,
  8. },
  9. start () {
  10. this.btn1.on('click', this.callback, this);
  11. this.btn2.on('click', this.callback, this);
  12. this.node.on(cc.Node.EventType.TOUCH_START, this.touchBegin.bind(this), this );
  13. },
  14. touchBegin: function(touch, envent) {
  15. },
  16. callback: function(t) {
  17. window.Utils.playSound('sound/button' , 2, false);
  18. var name = t.node.name;
  19. if (name == "offline_btn") {
  20. if (this.money != undefined) Module.money = Module.money+this.money;
  21. console.log("---this.money--: " , this.money);
  22. // this.node.destroy();
  23. Module.gameObj.updateMoney();
  24. this.node.active = false;
  25. window.Utils.playSound('sound/sell' , 2, false);
  26. window.Utils.playEffectSpine('effect/effect5/jb.json', 'action', Module.gameObj.node, 0.8);
  27. } else if (name == "video") {
  28. wb.ADManager.openAdC("video", function (a, result) {
  29. if(result == 0){
  30. if (this.money != undefined) Module.money = Module.money + (this.money* 10);
  31. Module.gameObj.updateMoney();
  32. // this.node.destroy();
  33. this.node.active = false;
  34. window.Utils.playSound('sound/sell' , 2, false);
  35. window.Utils.playEffectSpine('effect/effect5/jb.json', 'action', Module.gameObj.node, 0.8);
  36. }else{
  37. Module.gameObj.popupTishiLayer("视频未播放完~");
  38. }
  39. }.bind(this));
  40. }
  41. },
  42. init: function (money){
  43. this.money = money;
  44. this.num1.string = money;
  45. this.num2.string = money * 10;
  46. },
  47. // update (dt) {},
  48. });