SpeedUpUI.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. const { ccclass, property } = cc._decorator;
  2. @ccclass
  3. export default class SpeedUpUI extends cc.Component {
  4. @property(cc.Label)
  5. private lbl_reward_value: cc.Label = null;
  6. @property(cc.Sprite)
  7. private spr_cash_out: cc.Sprite = null;
  8. @property(cc.Label)
  9. private lbl_progress: cc.Label = null;
  10. @property(cc.Animation)
  11. private node_cash: cc.Animation = null;
  12. start(){
  13. this.initCashOutStyle(gData.gameData.gameData.redMoney);
  14. }
  15. update(dt){
  16. if (gData.reward.add_redbag_value) {
  17. this.initCashOutStyle(gData.gameData.gameData.redMoney + gData.reward.add_redbag_value);
  18. }
  19. }
  20. /**
  21. * 底部提现相关样式
  22. */
  23. private initCashOutStyle(redMoney: number = 0) {
  24. const cash_bar = gData.redBagCash.cash_bar;
  25. let cash_data = gData.redBagCash.getItemDataByIndex(cash_bar);
  26. if (!cash_data) return;
  27. const newRedMoney = redMoney > cash_data.type_value ? cash_data.type_value : redMoney;
  28. this.lbl_reward_value.string = cash_data.money / 100 + '元';
  29. this.lbl_progress.string = newRedMoney + '/' + cash_data.type_value;
  30. const fillRange = newRedMoney / cash_data.type_value >= 1 ? 1 : newRedMoney / cash_data.type_value;
  31. // this.spr_cash_out.fillRange = fillRange;
  32. cc.tween(this.spr_cash_out).to(fillRange, { fillRange: fillRange }).start();
  33. if (redMoney >= cash_data.type_value) {
  34. this.node_cash.play();
  35. } else {
  36. this.node_cash.stop();
  37. }
  38. }
  39. /**
  40. * 提现操作
  41. */
  42. private clickCashOut() {
  43. mk.audio.playEffect("button");
  44. gData.reward.addReward();
  45. mk.ui.closePanel(this.node.name);
  46. // let path = 'module/redBagCash/redBagCash';
  47. // mk.ui.openPanel(path);
  48. }
  49. private clickWatchVideoBtn()
  50. {
  51. mk.audio.playEffect("button");
  52. }
  53. private clickCloseBtn()
  54. {
  55. mk.audio.playEffect("closeButton");
  56. }
  57. }