giftLayer.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. cc.Class({
  2. extends: cc.Component,
  3. properties: {
  4. btn1: cc.Node,
  5. btn2: cc.Node,
  6. },
  7. start () {
  8. this.btn1.on('click', this.callback, this);
  9. this.btn2.on('click', this.callback, this);
  10. this.node.on(cc.Node.EventType.TOUCH_START, this.touchBegin.bind(this), this );
  11. },
  12. touchBegin: function(touch, envent) {
  13. },
  14. callback: function(t) {
  15. window.Utils.playSound('sound/button' , 2, false);
  16. var name = t.node.name;
  17. if (name == "close") {
  18. this.node.active = false;
  19. } else if (name == "video") {
  20. wb.ADManager.openAdC("video", function (a, result) {
  21. if(result == 0){
  22. Module.getGiftNum++;
  23. window.Utils.setIntegerForKey("diaoyu_getGiftNum" , Module.getGiftNum)
  24. Module.money = Module.money + 10000;
  25. Module.gameObj.updateMoney();
  26. this.node.active = false;
  27. window.Utils.playSound('sound/sell' , 2, false);
  28. window.Utils.playEffectSpine('effect/effect5/jb.json', 'action', Module.gameObj.node, 0.8);
  29. }else{
  30. Module.gameObj.popupTishiLayer("视频未播放完~");
  31. }
  32. }.bind(this));
  33. }
  34. },
  35. });