ClickAddMoney.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. const GameModule = require("../utils/GameModule");
  2. const DWTool = require('../utils/DWTool');
  3. const TapTapTool = require("../utils/TapTapTool");
  4. cc.Class({
  5. extends: cc.Component,
  6. properties: {
  7. addRichText: cc.RichText
  8. },
  9. // LIFE-CYCLE CALLBACKS:
  10. onLoad () {
  11. // this.node.zIndex = this.zIndex;
  12. // this.addLabel.active = false;
  13. },
  14. start () {
  15. },
  16. showAddMoney(showFinish, isAuto = false) {
  17. let money = TapTapTool.parseToString(GameModule.userInfo.coinTap);
  18. this.addRichText.string = `<b>+${money}</b>`;
  19. this.node.opacity = 255;
  20. let upAction = cc.moveBy(0.2, 0, 20);
  21. let fadeOutAction = cc.fadeOut(0.8);
  22. let upAction2 = cc.moveBy(0.8, 0, 80);
  23. let spaw = cc.spawn(fadeOutAction,upAction2);
  24. let callback = cc.callFunc(() => {
  25. this.node.active = false;
  26. if (showFinish) {
  27. showFinish();
  28. }
  29. });
  30. this.node.runAction(cc.sequence(upAction, spaw, callback));
  31. GameModule.userInfo.gold = TapTapTool.add(GameModule.userInfo.gold, GameModule.userInfo.coinTap);
  32. if (!isAuto) {
  33. GameModule.userInfo.clickCount += 1;
  34. }
  35. },
  36. // update (dt) {},
  37. });