SpeedUpUI.ts 2.1 KB

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